function FileCookieJarShimTest::testLegitimateInstanceAutoSavesOnDestruction
The jar must retain full functionality: auto-save on destruction.
File
-
core/
tests/ Drupal/ Tests/ Component/ Cookie/ FileCookieJarShimTest.php, line 70
Class
- FileCookieJarShimTest
- Tests the hardened backport of \GuzzleHttp\Cookie\FileCookieJar.
Namespace
Drupal\Tests\Component\CookieCode
public function testLegitimateInstanceAutoSavesOnDestruction() : void {
$jar = new FileCookieJar($this->file, TRUE);
$jar->setCookie(new SetCookie([
'Name' => 'sid',
'Value' => 'abc',
'Domain' => 'example.com',
'Expires' => time() + 3600,
]));
// Destroying a normally-constructed instance should persist cookies.
unset($jar);
gc_collect_cycles();
$this->assertFileExists($this->file, 'A normally-constructed FileCookieJar auto-saves on destruction.');
$reloaded = new FileCookieJar($this->file, TRUE);
$this->assertCount(1, $reloaded, 'Persisted cookies are reloaded by the constructor.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.