From aa7c2d6baaaebc99fbb000386f05096dbe2c9b7f Mon Sep 17 00:00:00 2001 From: Josh Grant Date: Sat, 15 Feb 2020 19:59:06 +0000 Subject: [PATCH] Fix cookie domain match (#5) * stub webdriver cookies as objects over arrays * check for cookie domain with isset, not array_key_exists calling array_key_exists on classes implementing \ArrayAccess always returns false and emits a deprecation notice on 7.4 --- src/Codeception/Module/WebDriver.php | 2 +- tests/web/WebDriverTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Codeception/Module/WebDriver.php b/src/Codeception/Module/WebDriver.php index 2b7a4b89..bcff0d37 100644 --- a/src/Codeception/Module/WebDriver.php +++ b/src/Codeception/Module/WebDriver.php @@ -3156,7 +3156,7 @@ public function deleteSessionSnapshot($name) */ private function cookieDomainMatchesConfigUrl($cookie) { - if (!array_key_exists('domain', $cookie)) { + if (!isset($cookie['domain'])) { return true; } diff --git a/tests/web/WebDriverTest.php b/tests/web/WebDriverTest.php index c85ed4ff..e31fc714 100644 --- a/tests/web/WebDriverTest.php +++ b/tests/web/WebDriverTest.php @@ -677,17 +677,17 @@ public function testSaveSessionSnapshotsExcludeInvalidCookieDomains() $fakeWdOptions = Stub::make('\Facebook\WebDriver\WebDriverOptions', [ 'getCookies' => Stub::atLeastOnce(function () { return [ - [ + Cookie::createFromArray([ 'name' => 'PHPSESSID', 'value' => '123456', 'path' => '/', - ], - [ + ]), + Cookie::createFromArray([ 'name' => '3rdParty', 'value' => '_value_', 'path' => '/', 'domain' => '.3rd-party.net', - ], + ]) ]; }), ]);