1
0
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:
Michael Dowling 2012-10-04 13:15:00 -07:00
parent eb06836d25
commit 2672b96685
2 changed files with 18 additions and 1 deletions

View File

@ -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);
}
}
}
}

View File

@ -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'));
}
}