Beispiel #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');
     }
 }
Beispiel #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) {
     }
 }
Beispiel #3
0
 public function testAsXml()
 {
     $command = new \TestCommand();
     $command->setApplication(new Application());
     $tester = new CommandTester($command);
     $tester->execute(array('command' => $command->getFullName()));
     $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command');
 }