Ejemplo n.º 1
0
 public function testGetNamespaceGetNameGetFullNameSetName()
 {
     $command = new \TestCommand();
     $this->assertEquals('namespace', $command->getNamespace(), '->getNamespace() returns the command namespace');
     $this->assertEquals('name', $command->getName(), '->getName() returns the command name');
     $this->assertEquals('namespace:name', $command->getFullName(), '->getNamespace() returns the full command name');
     $command->setName('foo');
     $this->assertEquals('foo', $command->getName(), '->setName() sets the command name');
     $command->setName(':bar');
     $this->assertEquals('bar', $command->getName(), '->setName() sets the command name');
     $this->assertEquals('', $command->getNamespace(), '->setName() can set the command namespace');
     $ret = $command->setName('foobar:bar');
     $this->assertEquals($command, $ret, '->setName() implements a fluent interface');
     $this->assertEquals('bar', $command->getName(), '->setName() sets the command name');
     $this->assertEquals('foobar', $command->getNamespace(), '->setName() can set the command namespace');
     try {
         $command->setName('');
         $this->fail('->setName() throws an \\InvalidArgumentException if the name is empty');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->setName() throws an \\InvalidArgumentException if the name is empty');
         $this->assertEquals('A command name cannot be empty.', $e->getMessage(), '->setName() throws an \\InvalidArgumentException if the name is empty');
     }
     try {
         $command->setName('foo:');
         $this->fail('->setName() throws an \\InvalidArgumentException if the name is empty');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->setName() throws an \\InvalidArgumentException if the name is empty');
         $this->assertEquals('A command name cannot be empty.', $e->getMessage(), '->setName() throws an \\InvalidArgumentException if the name is empty');
     }
 }
Ejemplo n.º 2
0
 public function testgetNamespaceGetNameGetFullNameSetName()
 {
     $command = new \TestCommand();
     $this->assertEquals($command->getNamespace(), 'namespace', '->getNamespace() returns the command namespace');
     $this->assertEquals($command->getName(), 'name', '->getName() returns the command name');
     $this->assertEquals($command->getFullName(), 'namespace:name', '->getNamespace() returns the full command name');
     $command->setName('foo');
     $this->assertEquals($command->getName(), 'foo', '->setName() sets the command name');
     $command->setName(':bar');
     $this->assertEquals($command->getName(), 'bar', '->setName() sets the command name');
     $this->assertEquals($command->getNamespace(), '', '->setName() can set the command namespace');
     $ret = $command->setName('foobar:bar');
     $this->assertEquals($ret, $command, '->setName() implements a fluent interface');
     $this->assertEquals($command->getName(), 'bar', '->setName() sets the command name');
     $this->assertEquals($command->getNamespace(), 'foobar', '->setName() can set the command namespace');
     try {
         $command->setName('');
         $this->fail('->setName() throws an \\InvalidArgumentException if the name is empty');
     } catch (\InvalidArgumentException $e) {
     }
     try {
         $command->setName('foo:');
         $this->fail('->setName() throws an \\InvalidArgumentException if the name is empty');
     } catch (\InvalidArgumentException $e) {
     }
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider provideInvalidCommandNames
  */
 public function testInvalidCommandNames($name)
 {
     $this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name));
     $command = new \TestCommand();
     $command->setName($name);
 }