[Console] Full coverage of Command class
This commit is contained in:
parent
28c0f493a2
commit
8ffe328fe6
@ -11,6 +11,7 @@
|
|||||||
namespace Symfony\Tests\Components\Console\Command;
|
namespace Symfony\Tests\Components\Console\Command;
|
||||||
|
|
||||||
use Symfony\Components\Console\Command\Command;
|
use Symfony\Components\Console\Command\Command;
|
||||||
|
use Symfony\Components\Console\Helper\FormatterHelper;
|
||||||
use Symfony\Components\Console\Application;
|
use Symfony\Components\Console\Application;
|
||||||
use Symfony\Components\Console\Input\InputDefinition;
|
use Symfony\Components\Console\Input\InputDefinition;
|
||||||
use Symfony\Components\Console\Input\InputArgument;
|
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');
|
$this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testgetNamespaceGetNameGetFullNameSetName()
|
public function testGetNamespaceGetNameGetFullNameSetName()
|
||||||
{
|
{
|
||||||
$command = new \TestCommand();
|
$command = new \TestCommand();
|
||||||
$this->assertEquals('namespace', $command->getNamespace(), '->getNamespace() returns the command namespace');
|
$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');
|
$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()
|
public function testMergeApplicationDefinition()
|
||||||
{
|
{
|
||||||
$application1 = new Application();
|
$application1 = new Application();
|
||||||
|
@ -35,4 +35,10 @@ class TestCommand extends Command
|
|||||||
{
|
{
|
||||||
$output->writeln('interact called');
|
$output->writeln('interact called');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHelper($name)
|
||||||
|
{
|
||||||
|
return parent::getHelper($name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user