Example #1
0
 /**
  * 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());
 }
Example #2
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()));
    }