Файл: vkolhoze.com/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ServiceDescriptionFactoryTest.php
Строк: 90
<?php
namespace GuzzleTestsServiceCommand;
use GuzzleServiceDescriptionServiceDescription;
use GuzzleServiceCommandFactoryServiceDescriptionFactory;
use GuzzleInflectionInflector;
/**
* @covers GuzzleServiceCommandFactoryServiceDescriptionFactory
*/
class ServiceDescriptionFactoryTest extends GuzzleTestsGuzzleTestCase
{
public function testProvider()
{
return array(
array('foo', null),
array('jar_jar', 'GuzzleTestsServiceMockCommandMockCommand'),
array('binks', 'GuzzleTestsServiceMockCommandOtherCommand')
);
}
/**
* @dataProvider testProvider
*/
public function testCreatesCommandsUsingServiceDescriptions($key, $result)
{
$d = $this->getDescription();
$factory = new ServiceDescriptionFactory($d);
$this->assertSame($d, $factory->getServiceDescription());
if (is_null($result)) {
$this->assertNull($factory->factory($key));
} else {
$this->assertInstanceof($result, $factory->factory($key));
}
}
public function testUsesUcFirstIfNoExactMatch()
{
$d = $this->getDescription();
$factory = new ServiceDescriptionFactory($d, new Inflector());
$this->assertInstanceof('GuzzleTestsServiceMockCommandOtherCommand', $factory->factory('Test'));
$this->assertInstanceof('GuzzleTestsServiceMockCommandOtherCommand', $factory->factory('test'));
}
public function testUsesInflectionIfNoExactMatch()
{
$d = $this->getDescription();
$factory = new ServiceDescriptionFactory($d, new Inflector());
$this->assertInstanceof('GuzzleTestsServiceMockCommandOtherCommand', $factory->factory('Binks'));
$this->assertInstanceof('GuzzleTestsServiceMockCommandOtherCommand', $factory->factory('binks'));
$this->assertInstanceof('GuzzleTestsServiceMockCommandMockCommand', $factory->factory('JarJar'));
$this->assertInstanceof('GuzzleTestsServiceMockCommandMockCommand', $factory->factory('jar_jar'));
}
protected function getDescription()
{
return ServiceDescription::factory(array(
'operations' => array(
'jar_jar' => array('class' => 'GuzzleTestsServiceMockCommandMockCommand'),
'binks' => array('class' => 'GuzzleTestsServiceMockCommandOtherCommand'),
'Test' => array('class' => 'GuzzleTestsServiceMockCommandOtherCommand')
)
));
}
}