Преглед изворни кода

[Console] Full coverage of Command class

Pascal Borreli пре 15 година
родитељ
комит
8ffe328fe6

+ 20 - 1
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();

+ 6 - 0
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);
+  }
+
 }