Skip to content

Commit

Permalink
Fix cookie domain match (#5)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Josh-G authored Feb 15, 2020
1 parent a41fae6 commit aa7c2d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Codeception/Module/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,7 @@ public function deleteSessionSnapshot($name)
*/
private function cookieDomainMatchesConfigUrl($cookie)
{
if (!array_key_exists('domain', $cookie)) {
if (!isset($cookie['domain'])) {
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/web/WebDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
])
];
}),
]);
Expand Down

0 comments on commit aa7c2d6

Please sign in to comment.