ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FigResponseCookiesTest.php
Go to the documentation of this file.
1<?php
2
3namespace Dflydev\FigCookies;
4
6{
10 public function it_gets_cookies()
11 {
13
15 ->withAddedHeader(SetCookies::SET_COOKIE_HEADER, SetCookie::create('theme', 'light'))
18 ;
19
20 $this->assertEquals(
21 'ENCRYPTED',
22 FigResponseCookies::get($response, 'sessionToken')->getValue()
23 );
24 }
25
29 public function it_sets_cookies()
30 {
32
34 ->withAddedHeader(SetCookies::SET_COOKIE_HEADER, SetCookie::create('theme', 'light'))
37 ;
38
40
41 $this->assertEquals(
42 'theme=light,sessionToken=ENCRYPTED,hello=WORLD%21',
43 $response->getHeaderLine('Set-Cookie')
44 );
45 }
46
50 public function it_modifies_cookies()
51 {
53
55 ->withAddedHeader(SetCookies::SET_COOKIE_HEADER, SetCookie::create('theme', 'light'))
58 ;
59
60 $response = FigResponseCookies::modify($response, 'hello', function (SetCookie $setCookie) {
61 return $setCookie->withValue(strtoupper($setCookie->getName()));
62 });
63
64 $this->assertEquals(
65 'theme=light,sessionToken=ENCRYPTED,hello=HELLO',
66 $response->getHeaderLine('Set-Cookie')
67 );
68 }
69
73 public function it_removes_cookies()
74 {
76
78 ->withAddedHeader(SetCookies::SET_COOKIE_HEADER, SetCookie::create('theme', 'light'))
81 ;
82
84
85 $this->assertEquals(
86 'theme=light,hello=world',
87 $response->getHeaderLine('Set-Cookie')
88 );
89 }
90}
An exception for terminatinating execution or to throw for unit testing.
static set(ResponseInterface $response, SetCookie $setCookie)
static get(ResponseInterface $response, $name, $value=null)
static modify(ResponseInterface $response, $name, $modify)
static remove(ResponseInterface $response, $name)
static create($name, $value=null)
Definition: SetCookie.php:173
const SET_COOKIE_HEADER
The name of the Set-Cookie header.
Definition: SetCookies.php:12
$response