public function ApplicationTest::testHasGet in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/console/Tests/ApplicationTest.php \Symfony\Component\Console\Tests\ApplicationTest::testHasGet()
File
- vendor/
symfony/ console/ Tests/ ApplicationTest.php, line 144
Class
Namespace
Symfony\Component\Console\TestsCode
public function testHasGet() {
$application = new Application();
$this
->assertTrue($application
->has('list'), '->has() returns true if a named command is registered');
$this
->assertFalse($application
->has('afoobar'), '->has() returns false if a named command is not registered');
$application
->add($foo = new \FooCommand());
$this
->assertTrue($application
->has('afoobar'), '->has() returns true if an alias is registered');
$this
->assertEquals($foo, $application
->get('foo:bar'), '->get() returns a command by name');
$this
->assertEquals($foo, $application
->get('afoobar'), '->get() returns a command by alias');
$application = new Application();
$application
->add($foo = new \FooCommand());
// simulate --help
$r = new \ReflectionObject($application);
$p = $r
->getProperty('wantHelps');
$p
->setAccessible(true);
$p
->setValue($application, true);
$command = $application
->get('foo:bar');
$this
->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $command, '->get() returns the help command if --help is provided as the input');
}