1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50:
<?php
namespace Guzzle\Tests\Service\Command;
use Guzzle\Tests\Service\Mock\MockClient;
use Guzzle\Service\Command\Factory\ConcreteClassFactory;
class ConcreteClassFactoryTest extends \Guzzle\Tests\GuzzleTestCase
{
public function testProvider()
{
return array(
array('foo', null, 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
array('mock_command', 'Guzzle\Tests\Service\Mock\Command\MockCommand', 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
array('other_command', 'Guzzle\Tests\Service\Mock\Command\OtherCommand', 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
array('sub.sub', 'Guzzle\Tests\Service\Mock\Command\Sub\Sub', 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
array('sub.sub', null, 'Guzzle\\Foo\\'),
array('foo', null, null),
array('mock_command', 'Guzzle\Tests\Service\Mock\Command\MockCommand', null),
array('other_command', 'Guzzle\Tests\Service\Mock\Command\OtherCommand', null),
array('sub.sub', 'Guzzle\Tests\Service\Mock\Command\Sub\Sub', null)
);
}
public function testCreatesConcreteCommands($key, $result, $prefix)
{
if (!$prefix) {
$client = new MockClient();
} else {
$client = new MockClient('', array(
'command.prefix' => $prefix
));
}
$factory = new ConcreteClassFactory($client);
if (is_null($result)) {
$this->assertNull($factory->factory($key));
} else {
$this->assertInstanceof($result, $factory->factory($key));
}
}
}