[Console] Full coverage of Command class

This commit is contained in:
Pascal Borreli 2010-04-08 16:54:36 -07:00 committed by Fabien Potencier
parent 28c0f493a2
commit 8ffe328fe6
2 changed files with 26 additions and 1 deletions

View File

@ -11,6 +11,7 @@
namespace Symfony\Tests\Components\Console\Command;
use Symfony\Components\Console\Command\Command;
use Symfony\Components\Console\Helper\FormatterHelper;
use Symfony\Components\Console\Application;
use Symfony\Components\Console\Input\InputDefinition;
use Symfony\Components\Console\Input\InputArgument;
@ -83,7 +84,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command');
}
public function testgetNamespaceGetNameGetFullNameSetName()
public function testGetNamespaceGetNameGetFullNameSetName()
{
$command = new \TestCommand();
$this->assertEquals('namespace', $command->getNamespace(), '->getNamespace() returns the command namespace');
@ -155,6 +156,24 @@ class CommandTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('namespace:name [--foo] [foo]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
}
public function testGetHelper()
{
$application = new Application();
$command = new \TestCommand();
$command->setApplication($application);
$formatterHelper = new FormatterHelper();
$this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper');
}
public function testGet()
{
$application = new Application();
$command = new \TestCommand();
$command->setApplication($application);
$formatterHelper = new FormatterHelper();
$this->assertEquals($formatterHelper->getName(), $command->formatter->getName(), '->__get() returns the correct helper');
}
public function testMergeApplicationDefinition()
{
$application1 = new Application();

View File

@ -35,4 +35,10 @@ class TestCommand extends Command
{
$output->writeln('interact called');
}
public function getHelper($name)
{
return parent::getHelper($name);
}
}