mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 02:22:57 +01:00
Fixing the merging of global default command parameters with explicitly specified command parameters
This commit is contained in:
parent
eb06836d25
commit
2672b96685
@ -129,7 +129,11 @@ class Client extends HttpClient implements ClientInterface
|
||||
// Add global client options to the command
|
||||
if ($command instanceof Collection) {
|
||||
if ($options = $this->getConfig(self::COMMAND_PARAMS)) {
|
||||
$command->merge($options);
|
||||
foreach ($options as $key => $value) {
|
||||
if (!$command->hasKey($key)) {
|
||||
$command->set($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,4 +374,17 @@ class ClientTest extends \Guzzle\Tests\GuzzleTestCase
|
||||
$client->setDescription($description);
|
||||
$this->assertEquals('http://foo.com', $client->getBaseUrl());
|
||||
}
|
||||
|
||||
public function testMergesDefaultCommandParamsCorrectly()
|
||||
{
|
||||
$client = new Mock\MockClient('http://www.foo.com', array(
|
||||
Client::COMMAND_PARAMS => array(
|
||||
'mesa' => 'bar',
|
||||
'jar' => 'jar'
|
||||
)
|
||||
));
|
||||
$command = $client->getCommand('mock_command', array('jar' => 'test'));
|
||||
$this->assertEquals('bar', $command->get('mesa'));
|
||||
$this->assertEquals('test', $command->get('jar'));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user