Open Monograph Press  3.3.0
ServiceDescriptionFactoryTest.php
1 <?php
2 
4 
8 
13 {
14  public function testProvider()
15  {
16  return array(
17  array('foo', null),
18  array('jar_jar', 'Guzzle\Tests\Service\Mock\Command\MockCommand'),
19  array('binks', 'Guzzle\Tests\Service\Mock\Command\OtherCommand')
20  );
21  }
22 
26  public function testCreatesCommandsUsingServiceDescriptions($key, $result)
27  {
28  $d = $this->getDescription();
29 
30  $factory = new ServiceDescriptionFactory($d);
31  $this->assertSame($d, $factory->getServiceDescription());
32 
33  if (is_null($result)) {
34  $this->assertNull($factory->factory($key));
35  } else {
36  $this->assertInstanceof($result, $factory->factory($key));
37  }
38  }
39 
41  {
42  $d = $this->getDescription();
43  $factory = new ServiceDescriptionFactory($d, new Inflector());
44  $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('Test'));
45  $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('test'));
46  }
47 
49  {
50  $d = $this->getDescription();
51  $factory = new ServiceDescriptionFactory($d, new Inflector());
52  $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('Binks'));
53  $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('binks'));
54  $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\MockCommand', $factory->factory('JarJar'));
55  $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\MockCommand', $factory->factory('jar_jar'));
56  }
57 
58  protected function getDescription()
59  {
60  return ServiceDescription::factory(array(
61  'operations' => array(
62  'jar_jar' => array('class' => 'Guzzle\Tests\Service\Mock\Command\MockCommand'),
63  'binks' => array('class' => 'Guzzle\Tests\Service\Mock\Command\OtherCommand'),
64  'Test' => array('class' => 'Guzzle\Tests\Service\Mock\Command\OtherCommand')
65  )
66  ));
67  }
68 }
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Service\Description\ServiceDescription\factory
static factory($config, array $options=array())
Definition: ServiceDescription.php:65
Guzzle\Service\Description\ServiceDescription
Definition: ServiceDescription.php:11
Guzzle\Tests\Service\Command\ServiceDescriptionFactoryTest\testUsesUcFirstIfNoExactMatch
testUsesUcFirstIfNoExactMatch()
Definition: ServiceDescriptionFactoryTest.php:40
Guzzle\Tests\Service\Command\ServiceDescriptionFactoryTest\getDescription
getDescription()
Definition: ServiceDescriptionFactoryTest.php:58
Guzzle\Tests\Service\Command\ServiceDescriptionFactoryTest
Definition: ServiceDescriptionFactoryTest.php:12
Guzzle\Tests\Service\Command\ServiceDescriptionFactoryTest\testCreatesCommandsUsingServiceDescriptions
testCreatesCommandsUsingServiceDescriptions($key, $result)
Definition: ServiceDescriptionFactoryTest.php:26
Guzzle\Tests\Service\Command\ServiceDescriptionFactoryTest\testUsesInflectionIfNoExactMatch
testUsesInflectionIfNoExactMatch()
Definition: ServiceDescriptionFactoryTest.php:48
Guzzle\Inflection\Inflector
Definition: Inflector.php:8
Guzzle\Tests\Service\Command\ServiceDescriptionFactoryTest\testProvider
testProvider()
Definition: ServiceDescriptionFactoryTest.php:14
Guzzle\Service\Command\Factory\ServiceDescriptionFactory
Definition: ServiceDescriptionFactory.php:11
Guzzle\Tests\Service\Command
Definition: AbstractCommandTest.php:3