Last active
August 29, 2015 14:07
-
-
Save gnugat/400729d3f97fd2ed7fc9 to your computer and use it in GitHub Desktop.
gnugat/ripozi - CommandTestApplication
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
<?php | |
namespace Gnugat\Ripozi\Test; | |
use Symfony\Bundle\FrameworkBundle\Console\Application; | |
use Symfony\Component\Console\Input\ArrayInput; | |
use Symfony\Component\Console\Output\NullOutput; | |
/** | |
* Assumes that the application kernel is named AppKernel and has been loaded | |
*/ | |
class CommandTestApplication | |
{ | |
const EXIT_SUCCESS = 0; | |
/** | |
* @var Application | |
*/ | |
private $application; | |
/** | |
* @var \Symfony\Component\DependencyInjection\ContainerInterface | |
*/ | |
private $container; | |
/** | |
* @var \Symfony\Component\HttpKernel\KernelInterface | |
*/ | |
private $kernel; | |
public function __construct() | |
{ | |
$this->kernel = new \AppKernel('test', true); | |
$this->kernel->boot(); | |
$this->container = $this->kernel->getContainer(); | |
$this->application = new Application($this->kernel); | |
$this->application->setAutoExit(false); | |
} | |
/** | |
* @param array $rawInput | |
* | |
* @return int | |
*/ | |
public function run(array $rawInput) | |
{ | |
$input = new ArrayInput($rawInput); | |
$output = new NullOutput(); | |
return $this->application->run($input, $output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: