Пример #1
0
 public function testFindNamespace()
 {
     $application = new TestApplication();
     $application->addCommand(new \FooCommand());
     $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists');
     $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation');
     $application->addCommand(new \Foo2Command());
     $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists');
     try {
         $application->findNamespace('f');
         $this->fail('->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous');
         $this->assertEquals('The namespace "f" is ambiguous (foo, foo1).', $e->getMessage(), '->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous');
     }
     try {
         $application->findNamespace('bar');
         $this->fail('->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace');
         $this->assertEquals('There are no commands defined in the "bar" namespace.', $e->getMessage(), '->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace');
     }
 }
Пример #2
0
 public function testFindNamespace()
 {
     $application = new TestApplication();
     $application->addCommand(new \FooCommand());
     $this->assertEquals($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists');
     $this->assertEquals($application->findNamespace('f'), 'foo', '->findNamespace() finds a namespace given an abbreviation');
     $application->addCommand(new \Foo2Command());
     $this->assertEquals($application->findNamespace('foo'), 'foo', '->findNamespace() returns the given namespace if it exists');
     try {
         $application->findNamespace('f');
         $this->fail('->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous');
     } catch (\InvalidArgumentException $e) {
     }
     try {
         $application->findNamespace('bar');
         $this->fail('->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace');
     } catch (\InvalidArgumentException $e) {
     }
 }