Skip to content

Commit

Permalink
Merge branch 'JorisVanEijden-5401-non-null-cookie-expiry' into 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Naktibalda committed Mar 23, 2019
2 parents 367de4f + 396f21f commit 2a5b4e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/Codeception/Module/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,14 @@ public function setCookie($cookie, $value, array $params = [])
$params['domain'] = $urlParts['host'];
}
}
// #5401 Supply defaults, otherwise chromedriver 2.46 complains.
$params = array_filter($params);
$params += [
'path' => '/',
'expiry' => time() + 86400,
'secure' => false,
'httpOnly' => false,
];
$this->webDriver->manage()->addCookie($params);
$this->debugSection('Cookies', json_encode($this->webDriver->manage()->getCookies()));
}
Expand Down Expand Up @@ -3097,7 +3105,7 @@ public function loadSessionSnapshot($name)
}

foreach ($this->sessionSnapshots[$name] as $cookie) {
$this->webDriver->manage()->addCookie($cookie);
$this->setCookie($cookie->getName(), $cookie->getValue(), $cookie->toArray());
}
$this->debugSection('Snapshot', "Restored \"$name\" session snapshot");
return true;
Expand Down
9 changes: 5 additions & 4 deletions tests/web/WebDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Codeception\Step;
use Codeception\Util\Stub;
use Facebook\WebDriver\Cookie;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\WebDriverBy;
Expand Down Expand Up @@ -675,17 +676,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 2a5b4e5

Please sign in to comment.