->
withDomain('.myfoodomain.com'
) ->
withSecure(true
) ->
withSameSite(null
);
$this->
assertEquals($expected,
(string) $cookie, '->__toString() encodes the value of the cookie according to RFC 3986 (white space = %20)'
);
$expected = 'foo=deleted; expires='.
gmdate('D, d M Y H:i:s T',
$expire =
time() - 31536001
).'; Max-Age=0; path=/admin/; domain=.myfoodomain.com; httponly';
$cookie = Cookie::
create('foo', null, 1, '/admin/', '.myfoodomain.com', false, true, false, null
);
$this->
assertEquals($expected,
(string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL'
);
$cookie = Cookie::
create('foo'
) ->
withExpires(1
) ->
withPath('/admin/'
) ->
withDomain('.myfoodomain.com'
) ->
withSameSite(null
);
$this->
assertEquals($expected,
(string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL'
);
$expected = 'foo=bar; path=/; httponly; samesite=lax';
$cookie = Cookie::
create('foo', 'bar'
);
$this->
assertEquals($expected,
(string) $cookie);
$cookie = Cookie::
create('foo'
)->
withValue('bar'
);
$this->
assertEquals($expected,
(string) $cookie);
}