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
 public function testGetNamespaceGetNameSetName()
 {
     $command = new \TestCommand();
     $this->assertEquals('namespace:name', $command->getName(), '->getName() returns the command name');
     $command->setName('foo');
     $this->assertEquals('foo', $command->getName(), '->setName() sets the command name');
     $ret = $command->setName('foobar:bar');
     $this->assertEquals($command, $ret, '->setName() implements a fluent interface');
     $this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name');
 }
Ejemplo n.º 4
0
 public function testAsXml()
 {
     $command = new \TestCommand();
     $command->setApplication(new Application());
     $tester = new CommandTester($command);
     $tester->execute(array('command' => $command->getName()));
     $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command');
 }
Ejemplo n.º 5
0
 public function testLegacyAsXml()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $command = new \TestCommand();
     $command->setApplication(new Application());
     $tester = new CommandTester($command);
     $tester->execute(array('command' => $command->getName()));
     $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command');
 }
 public function testBaseCommandClassIsCalled()
 {
     $this->assertEquals($this->commandName, $this->command->getName());
 }