From 8ffe328fe6543f2c18cb08d049fcb7bf6f29571f Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Thu, 8 Apr 2010 16:54:36 -0700 Subject: [PATCH] [Console] Full coverage of Command class --- .../Console/Command/CommandTest.php | 21 ++++++++++++++++++- .../Components/Console/TestCommand.php | 6 ++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/Symfony/Tests/Components/Console/Command/CommandTest.php b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php index c0aba57905..fd8706dc21 100644 --- a/tests/Symfony/Tests/Components/Console/Command/CommandTest.php +++ b/tests/Symfony/Tests/Components/Console/Command/CommandTest.php @@ -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(); diff --git a/tests/fixtures/Symfony/Components/Console/TestCommand.php b/tests/fixtures/Symfony/Components/Console/TestCommand.php index 751570f2e3..c04743d319 100644 --- a/tests/fixtures/Symfony/Components/Console/TestCommand.php +++ b/tests/fixtures/Symfony/Components/Console/TestCommand.php @@ -35,4 +35,10 @@ class TestCommand extends Command { $output->writeln('interact called'); } + + public function getHelper($name) + { + return parent::getHelper($name); + } + }