2010-03-18 07:48:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2010-04-25 16:06:54 +01:00
|
|
|
* This file is part of the Symfony package.
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-03-18 07:48:03 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
namespace Symfony\Tests\Component\Console\Tester;
|
2010-03-18 07:48:03 +00:00
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\Console\Application;
|
|
|
|
use Symfony\Component\Console\Output\Output;
|
|
|
|
use Symfony\Component\Console\Tester\ApplicationTester;
|
2010-03-18 07:48:03 +00:00
|
|
|
|
|
|
|
class ApplicationTesterTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2010-05-06 12:25:53 +01:00
|
|
|
protected $application;
|
|
|
|
protected $tester;
|
|
|
|
|
2010-12-06 14:45:37 +00:00
|
|
|
protected function setUp()
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
|
|
|
$this->application = new Application();
|
|
|
|
$this->application->setAutoExit(false);
|
|
|
|
$this->application->register('foo')
|
|
|
|
->addArgument('command')
|
|
|
|
->addArgument('foo')
|
|
|
|
->setCode(function ($input, $output) { $output->writeln('foo'); })
|
|
|
|
;
|
|
|
|
|
|
|
|
$this->tester = new ApplicationTester($this->application);
|
|
|
|
$this->tester->run(array('command' => 'foo', 'foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testRun()
|
|
|
|
{
|
|
|
|
$this->assertFalse($this->tester->getInput()->isInteractive(), '->execute() takes an interactive option');
|
|
|
|
$this->assertFalse($this->tester->getOutput()->isDecorated(), '->execute() takes a decorated option');
|
|
|
|
$this->assertEquals(Output::VERBOSITY_VERBOSE, $this->tester->getOutput()->getVerbosity(), '->execute() takes a verbosity option');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetInput()
|
|
|
|
{
|
|
|
|
$this->assertEquals('bar', $this->tester->getInput()->getArgument('foo'), '->getInput() returns the current input instance');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetOutput()
|
|
|
|
{
|
|
|
|
rewind($this->tester->getOutput()->getStream());
|
|
|
|
$this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetDisplay()
|
|
|
|
{
|
|
|
|
$this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution');
|
|
|
|
}
|
2010-03-18 07:48:03 +00:00
|
|
|
}
|