コード例 #1
0
 /**
  * Run the flo new-release command.
  *
  * @param string $increment
  *   (Optional) A valid semantic version or major|minor|patch
  *
  * @return CommandTester
  */
 private function runNewRelease($increment = '0.0.0')
 {
     $application = new Application();
     $command_new_release = $application->find('new-release');
     $commandTester = new CommandTester($command_new_release);
     $commandTester->execute(array('command' => $command_new_release->getName(), 'increment' => $increment));
     return $commandTester;
 }
コード例 #2
0
 /**
  * Test the config-get, config-set, & config-del as a group.
  */
 public function testExecuteConfigOptions()
 {
     $application = new Application();
     $command_get = $application->find('config-get');
     $command_set = $application->find('config-set');
     $command_del = $application->find('config-del');
     // flo should complain about missing config file 1st.
     $commandTester = new CommandTester($command_get);
     $commandTester->execute(array('command' => $command_get->getName()));
     $this->assertContains('No flo config file exist.', $commandTester->getDisplay());
     // Lets try and delete a key without a config file
     $commandTester = new CommandTester($command_del);
     $commandTester->execute(array('command' => $command_del->getName(), 'config-name' => 'test1'));
     $this->assertContains('No flo config file exist.', $commandTester->getDisplay());
     // Lets set a couple of config value. flo should confirm it saved it.
     $commandTester = new CommandTester($command_set);
     $commandTester->execute(array('command' => $command_set->getName(), 'config-name' => 'test1', 'config-value' => 'test1'));
     $this->assertContains('test1: test1 has been saved.', $commandTester->getDisplay());
     $commandTester = new CommandTester($command_set);
     $commandTester->execute(array('command' => $command_set->getName(), 'config-name' => 'test2', 'config-value' => 'test2'));
     $this->assertContains('test2: test2 has been saved.', $commandTester->getDisplay());
     // Lets try to get the value via config-get now.
     $commandTester = new CommandTester($command_get);
     $commandTester->execute(array('command' => $command_get->getName(), 'config' => 'test1'));
     $this->assertContains('test1: test1', $commandTester->getDisplay());
     // Now lets delete the test1 key.
     $commandTester = new CommandTester($command_del);
     $commandTester->execute(array('command' => $command_del->getName(), 'config-name' => 'test1'));
     $this->assertContains('test1 has been deleted.', $commandTester->getDisplay());
     // Now lets try and delete the same key key.
     $commandTester = new CommandTester($command_del);
     $commandTester->execute(array('command' => $command_del->getName(), 'config-name' => 'test1'));
     $this->assertContains("No config key 'test1'", $commandTester->getDisplay());
     // Now lets try and get the test1 key.
     $commandTester = new CommandTester($command_get);
     $commandTester->execute(array('command' => $command_get->getName(), 'config' => 'test1'));
     $this->assertContains("No configuration set for 'test1'", $commandTester->getDisplay());
     // Lets try to get all the value via config-get now.
     $commandTester = new CommandTester($command_get);
     $commandTester->execute(array('command' => $command_get->getName()));
     $this->assertContains('test2: test2', $commandTester->getDisplay());
     // Now lets test with an array of options.
     file_put_contents($_ENV['HOME'] . '/.config/flo', "acquia: { username: eric.duran@nbcuni.com, password: TESTING }");
     $commandTester = new CommandTester($command_get);
     $commandTester->execute(array('command' => $command_get->getName()));
     $expected = "acquia:\n  username: eric.duran@nbcuni.com\n  password: TESTING";
     $this->assertContains($expected, $commandTester->getDisplay());
 }
コード例 #3
0
ファイル: ApplicationTest.php プロジェクト: rabellamy/flo
 /**
  * Test Successful doRun.
  */
 function testExistingHubApplication()
 {
     // Create a Mock Process Object.
     $process = $this->getMockBuilder('Symfony\\Component\\Process\\Process')->disableOriginalConstructor()->getMock();
     // Make sure the isSuccessful method return FALSE so flo throws an exception.
     $process->method('isSuccessful')->willReturn(TRUE);
     $app = new Console\Application();
     // Set autoExit to false when testing & do not let it catch exceptions.
     $app->setAutoExit(FALSE);
     // Overwrite Symfony\Component\Process\Process with our mock Process.
     $app->setProcess($process);
     // Run a command and wait for the exception.
     $appTester = new ApplicationTester($app);
     $appTester->run(array('command' => 'help'));
     $this->assertEquals(0, $appTester->getStatusCode());
 }
コード例 #4
0
    /**
     * Test run-script sh process failing.
     */
    public function testSHScripException()
    {
        $this->writeConfig();
        // Create scripts/post-deploy.sh.
        $post_deploy_script = <<<EOT
#!/usr/bin/env bash
echo "hello \$1"
EOT;
        $this->fs->dumpFile($this->root . "/scripts/post-deploy.sh", $post_deploy_script);
        // Create a Mock Process Object.
        $process = $this->getMockBuilder('Symfony\\Component\\Process\\Process')->disableOriginalConstructor()->getMock();
        // Make sure the isSuccessful method return FALSE so flo throws an exception.
        $process->method('isSuccessful')->willReturn(FALSE);
        $process->method('getErrorOutput')->willReturn('sh failed');
        // Run the command.
        $app = new Application();
        // Set autoExit to false when testing & do not let it catch exceptions.
        $app->setAutoExit(TRUE);
        $app->setCatchExceptions(FALSE);
        $app->setProcess($process);
        $command_run_script = $app->find('run-script');
        $command_tester = new CommandTester($command_run_script);
        $command_tester->execute(array('command' => $command_run_script->getName(), 'script' => 'post_deploy_cmd', 'args' => array('world')));
        // Check the output of the command.
        $this->assertEquals("sh failed", trim($command_tester->getDisplay()));
    }