Skip to content

Commit dd91131

Browse files
committed
Fix hooks processing in cURL tests
1 parent 30afc43 commit dd91131

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Transport/Curl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function request($url, $headers = [], $data = [], $options = []) {
191191

192192
$this->setup_handle($url, $headers, $data, $options);
193193

194-
$options['hooks']->dispatch('curl.before_send', array(&$this->handle));
194+
$options['hooks']->dispatch('curl.before_send', [&$this->handle]);
195195

196196
$this->response_data = '';
197197
$this->response_bytes = 0;

tests/Transport/Curl/CurlTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,22 @@ final class CurlTest extends BaseTestCase {
2929
* @param array $other
3030
* @return array
3131
*/
32-
protected function getOptions($other = array()) {
32+
protected function getOptions($other = []) {
3333
$options = parent::getOptions($other);
3434

3535
$this->curl_handle = null;
3636

37-
$hooks = new Hooks();
38-
$hooks->register(
37+
if (!array_key_exists('hooks', $options)) {
38+
$options['hooks'] = new Hooks();
39+
}
40+
41+
$options['hooks']->register(
3942
'curl.before_request',
4043
function ($handle) {
4144
$this->curl_handle = $handle;
4245
}
4346
);
4447

45-
$options['hooks'] = $hooks;
46-
4748
return $options;
4849
}
4950

0 commit comments

Comments
 (0)