From dd91131079c34b938828af83bdd165259e4b7daa Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 10 Nov 2021 18:51:52 +0100 Subject: [PATCH] Fix hooks processing in cURL tests --- src/Transport/Curl.php | 2 +- tests/Transport/Curl/CurlTest.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Transport/Curl.php b/src/Transport/Curl.php index 532883b4c..bb85345aa 100644 --- a/src/Transport/Curl.php +++ b/src/Transport/Curl.php @@ -191,7 +191,7 @@ public function request($url, $headers = [], $data = [], $options = []) { $this->setup_handle($url, $headers, $data, $options); - $options['hooks']->dispatch('curl.before_send', array(&$this->handle)); + $options['hooks']->dispatch('curl.before_send', [&$this->handle]); $this->response_data = ''; $this->response_bytes = 0; diff --git a/tests/Transport/Curl/CurlTest.php b/tests/Transport/Curl/CurlTest.php index 7d4b0c8fa..709efd866 100644 --- a/tests/Transport/Curl/CurlTest.php +++ b/tests/Transport/Curl/CurlTest.php @@ -29,21 +29,22 @@ final class CurlTest extends BaseTestCase { * @param array $other * @return array */ - protected function getOptions($other = array()) { + protected function getOptions($other = []) { $options = parent::getOptions($other); $this->curl_handle = null; - $hooks = new Hooks(); - $hooks->register( + if (!array_key_exists('hooks', $options)) { + $options['hooks'] = new Hooks(); + } + + $options['hooks']->register( 'curl.before_request', function ($handle) { $this->curl_handle = $handle; } ); - $options['hooks'] = $hooks; - return $options; }