1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-24 18:13:00 +01:00

Add newly set ServiceDescription objects to CompositeFactory (#565).

This commit is contained in:
Diego Agulló 2014-02-16 03:08:22 +01:00
parent c03449e883
commit ed3a1a731e
3 changed files with 57 additions and 0 deletions

View File

@ -147,6 +147,10 @@ class Client extends HttpClient implements ClientInterface
{
$this->serviceDescription = $service;
if ($this->getCommandFactory() && $this->getCommandFactory() instanceof CompositeFactory) {
$this->commandFactory->add(new Command\Factory\ServiceDescriptionFactory($service));
}
// If a baseUrl was set on the description, then update the client
if ($baseUrl = $service->getBaseUrl()) {
$this->setBaseUrl($baseUrl);

View File

@ -304,4 +304,17 @@ class ClientTest extends \Guzzle\Tests\GuzzleTestCase
}
}
}
public function testGetCommandAfterTwoSetDescriptions()
{
$service1 = ServiceDescription::factory(__DIR__ . '/../TestData/test_service.json');
$service2 = ServiceDescription::factory(__DIR__ . '/../TestData/test_service_3.json');
$client = new Mock\MockClient();
$client->setDescription($service1);
$client->getCommand('foo_bar');
$client->setDescription($service2);
$client->getCommand('baz_qux');
}
}

View File

@ -0,0 +1,40 @@
{
"includes": [ "test_service2.json" ],
"operations": {
"test": {
"uri": "/path"
},
"concrete": {
"extends": "abstract"
},
"baz_qux": {
"uri": "/testing",
"parameters": {
"other": {
"location": "json",
"location_key": "Other"
},
"test": {
"type": "object",
"location": "json",
"properties": {
"baz": {
"type": "boolean",
"default": true
},
"bar": {
"type": "string",
"filters": [
{
"method": "strtolower",
"args": ["test", "@value"]
},
"strtoupper"
]
}
}
}
}
}
}
}