-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing pr-deploy to not try and deploy with a pr_directories being set
- Loading branch information
Showing
2 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
tests/flo/Test/Command/PullRequest/DeployCommandTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
namespace flo\Test\Command\PullRequest; | ||
|
||
use flo\Console\Application; | ||
use flo\SymfonyOverwrite\Filesystem; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
use Symfony\Component\Process\Process; | ||
|
||
|
||
class DeployCommandTest extends \PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* The root project directory. | ||
* | ||
* @var string | ||
*/ | ||
private $root; | ||
|
||
/** | ||
* Filesystem object. | ||
* | ||
* @var Filesystem | ||
*/ | ||
private $fs; | ||
|
||
/** | ||
* Set up test environment filesystem. | ||
*/ | ||
public function setUp() { | ||
|
||
$this->fs = new Filesystem(); | ||
|
||
// Attempt to create a temporary directory for the tests and change the | ||
// current working directory to that directory. | ||
try { | ||
$this->root = sys_get_temp_dir() . '/' . str_replace('\\', '-', __CLASS__); | ||
if ($this->fs->exists($this->root)) { | ||
$this->fs->remove($this->root); | ||
} | ||
$this->fs->mkdir($this->root); | ||
} | ||
catch (\Exception $e) { | ||
$this->tearDown(); | ||
// Throw the exception again so the tests will be skipped. | ||
throw $e; | ||
} | ||
chdir($this->root); | ||
|
||
// Setup a git repo. | ||
$process = new Process('git init'); | ||
$process->run(); | ||
} | ||
|
||
/** | ||
* Test Running pr-deploy without pr_directories set. | ||
* | ||
* @expectedException Exception | ||
* @expectedExceptionMessageRegExp #You must have a pr_directory set in your flo config.# | ||
*/ | ||
public function testMissingPRDirectoryConfig() { | ||
$this->writeConfig(); | ||
|
||
// Run the command. | ||
$application = new Application(); | ||
$command_run_script = $application->find('pr-deploy'); | ||
$command_tester = new CommandTester($command_run_script); | ||
$command_tester->execute(array( | ||
'command' => $command_run_script->getName(), | ||
'pull-request' => 1, | ||
)); | ||
} | ||
|
||
|
||
/** | ||
* Helper function to write configuration file. | ||
*/ | ||
private function writeConfig() { | ||
// Create a sample flo.yml file. | ||
$project_config = <<<EOT | ||
--- | ||
organization: NBCUOTS | ||
repository: Publisher7_nbcuflo | ||
shortname: Publisher7_nbcuflo | ||
github_git_uri: [email protected]:NBCUOTS/Publisher7_nbcuflo.git | ||
pull_request: | ||
domain: pr.publisher7.com | ||
prefix: flo-test | ||
EOT; | ||
$this->fs->dumpFile($this->root . "/flo.yml", $project_config); | ||
} | ||
|
||
/** | ||
* Remove the files and directories created for this test. | ||
*/ | ||
public function tearDown() { | ||
if ($this->fs->exists($this->root)) { | ||
$this->fs->remove($this->root); | ||
} | ||
} | ||
} |