public function CookieMonsterTest::testFoo in Bakery Single Sign-On System 8.2
@covers ::meWantCookie
File
- tests/
src/ Unit/ EventSubscriber/ CookieMonsterTest.php, line 70
Class
- CookieMonsterTest
- @coversDefaultClass \Drupal\bakery\EventSubscriber\CookieMonster
Namespace
Drupal\Tests\bakery\Unit\EventSubscriberCode
public function testFoo() {
$response = new Response();
$event = new ResponseEvent($this
->prophesize(HttpKernelInterface::class)
->reveal(), $this->request
->getCurrentRequest(), HttpKernelInterface::MASTER_REQUEST, $response);
$this->sot
->meWantCookie($event);
$this
->assertCount(0, $response->headers
->getCookies());
$this->cookieJar
->set('cookie1', 'foo');
$this->cookieJar
->set('cookie2', 'bar');
$this->cookieJar
->set('cookie3', '');
$this->sot
->meWantCookie($event);
$this
->assertCount(4, $response->headers
->getCookies());
$expire = $this->time
->getRequestTime() + 3600;
$secure = !empty(ini_get('session.cookie_secure'));
$this
->assertEquals([
Cookie::create('cookie1', 'foo', $expire, '/', '.example.com', $secure),
Cookie::create('cookie2', 'bar', $expire, '/', '.example.com', $secure),
// This might cause problems with Symfony 5?
new Cookie('cookie3', NULL, 1, '/', '.example.com', $secure, TRUE, FALSE, NULL),
new Cookie('cookie3', NULL, 1, '/', '', $secure, TRUE, FALSE, NULL),
], $response->headers
->getCookies());
}