Skip to content

Commit

Permalink
Fix constructor options completely overwriting defaults.
Browse files Browse the repository at this point in the history
Constructor arguments should augment not replace the defaults.
  • Loading branch information
markstory committed Dec 31, 2012
1 parent 99a5f72 commit 37b9527
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Network/Http/Client.php
Expand Up @@ -129,7 +129,7 @@ public function __construct($config = []) {
$adapter = $config['adapter'];
unset($config['adapter']);
}
$this->_config = $config;
$this->config($config);

if (is_string($adapter)) {
$adapter = new $adapter();
Expand Down
9 changes: 7 additions & 2 deletions lib/Cake/Test/TestCase/Network/Http/ClientTest.php
Expand Up @@ -34,7 +34,10 @@ public function testConstructConfig() {
'host' => 'example.org',
];
$http = new Client($config);
$this->assertEquals($config, $http->config());
$result = $http->config();
foreach ($config as $key => $val) {
$this->assertEquals($val, $result[$key]);
}

$result = $http->config([
'auth' => ['username' => 'mark', 'password' => 'secret']
Expand All @@ -47,7 +50,9 @@ public function testConstructConfig() {
'host' => 'example.org',
'auth' => ['username' => 'mark', 'password' => 'secret']
];
$this->assertEquals($expected, $result);
foreach ($config as $key => $val) {
$this->assertEquals($val, $result[$key]);
}
}

/**
Expand Down

0 comments on commit 37b9527

Please sign in to comment.