ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FigRequestCookiesTest.php
Go to the documentation of this file.
1<?php
2
3namespace Dflydev\FigCookies;
4
6{
10 public function it_gets_cookies()
11 {
13 ->withHeader(Cookies::COOKIE_HEADER, 'theme=light; sessionToken=RAPELCGRQ; hello=world')
14 ;
15
16 $this->assertEquals(
17 'RAPELCGRQ',
18 FigRequestCookies::get($request, 'sessionToken')->getValue()
19 );
20 }
21
25 public function it_sets_cookies()
26 {
28 ->withHeader(Cookies::COOKIE_HEADER, 'theme=light; sessionToken=RAPELCGRQ; hello=world')
29 ;
30
32
33 $this->assertEquals(
34 'theme=light; sessionToken=RAPELCGRQ; hello=WORLD%21',
35 $request->getHeaderLine('Cookie')
36 );
37 }
38
42 public function it_modifies_cookies()
43 {
45 ->withHeader(Cookies::COOKIE_HEADER, 'theme=light; sessionToken=RAPELCGRQ; hello=world')
46 ;
47
48 $request = FigRequestCookies::modify($request, 'hello', function (Cookie $cookie) {
49 return $cookie->withValue(strtoupper($cookie->getName()));
50 });
51
52 $this->assertEquals(
53 'theme=light; sessionToken=RAPELCGRQ; hello=HELLO',
54 $request->getHeaderLine('Cookie')
55 );
56 }
57
61 public function it_removes_cookies()
62 {
64 ->withHeader(Cookies::COOKIE_HEADER, 'theme=light; sessionToken=RAPELCGRQ; hello=world')
65 ;
66
68
69 $this->assertEquals(
70 'theme=light; hello=world',
71 $request->getHeaderLine('Cookie')
72 );
73 }
74}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
withValue($value=null)
Definition: Cookie.php:47
static create($name, $value=null)
Create a Cookie.
Definition: Cookie.php:73
const COOKIE_HEADER
The name of the Cookie header.
Definition: Cookies.php:12
static remove(RequestInterface $request, $name)
static get(RequestInterface $request, $name, $value=null)
static modify(RequestInterface $request, $name, $modify)
static set(RequestInterface $request, Cookie $cookie)