/**
  * {@inheritdoc}
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $cookieName = 'encrypted-cookie-test';
     $cookie = $this->cookie->getCookie($request, $cookieName) ?: 'Not Found (Are encrypted cookies enabled?)';
     $cookieTest = "\nCookie test: {$cookie}";
     $contents = str_replace('{cookie}', $cookieTest, self::HTML);
     $response->getBody()->write($contents);
     return $this->cookie->withCookie($response, $cookieName, 'testing-' . \random_int(100, 200));
 }
 public function testSetCookieWithConfiguration()
 {
     $handler = new CookieHandler(['expires' => '+30 days', 'maxAge' => '', 'path' => '/page', 'domain' => 'example.com', 'secure' => true, 'httpOnly' => true]);
     $response = $handler->withCookie($this->response, 'testcookie1', 'value1', '+7 days');
     $cookie = $response->getHeaderLine('Set-Cookie');
     $this->assertContains('testcookie1=%5Bopaque+property%5D;', $cookie);
     $this->assertContains('Domain=example.com;', $cookie);
     $this->assertContains('Path=/page;', $cookie);
     $this->assertContains('Secure;', $cookie);
     $this->assertContains('HttpOnly', $cookie);
     $this->assertContains('Expires=', $cookie);
 }