/** @dataProvider getDescribeApplicationTestData */
 public function testDescribeApplication(Application $application, $expectedDescription)
 {
     // Replaces the dynamic placeholders of the command help text with a static version.
     // The placeholder %command.full_name% includes the script path that is not predictable
     // and can not be tested against.
     foreach ($application->all() as $command) {
         $command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp()));
     }
     $this->assertDescription($expectedDescription, $application);
 }
 private function inspectApplication()
 {
     $this->commands = array();
     $this->namespaces = array();
     $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
     foreach ($this->sortCommands($all) as $namespace => $commands) {
         $names = array();
         /** @var AbstractCommand $command */
         foreach ($commands as $name => $command) {
             if (!$command->getName()) {
                 continue;
             }
             if ($command->getName() === $name) {
                 $this->commands[$name] = $command;
             } else {
                 $this->aliases[$name] = $command;
             }
             $names[] = $name;
         }
         $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
     }
 }
Example #3
0
 public function testAdd()
 {
     $application = new Application();
     $application->add($foo = new \FooCommand());
     $commands = $application->all();
     $this->assertEquals($foo, $commands['foo:bar'], '->add() registers a command');
     $application = new Application();
     $application->addCommands(array($foo = new \FooCommand(), $foo1 = new \Foo1Command()));
     $commands = $application->all();
     $this->assertEquals(array($foo, $foo1), array($commands['foo:bar'], $commands['foo:bar1']), '->addCommands() registers an array of commands');
 }