forked from miyagawa/HTTPx-Weblet
/
cookie.t
37 lines (34 loc) · 831 Bytes
/
cookie.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;
use warnings;
use Test::More tests => 7;
use t::Utils;
use HTTP::Request;
use CGI::Simple::Cookie;
# exist Cookie header.
do {
# do test
do {
my $req = req(
HTTP_COOKIE => 'Foo=Bar; Bar=Baz',
REQUEST_METHOD => 'GET',
SCRIPT_NAME => '/',
);
is '2', $req->cookie;
is $req->cookie('undef'), undef;
is $req->cookie('undef', 'undef'), undef;
is $req->cookie('Foo')->value, 'Bar';
is $req->cookie('Bar')->value, 'Baz';
is_deeply $req->cookies, {Foo => 'Foo=Bar; path=/', Bar => 'Bar=Baz; path=/'};
};
};
# no Cookie header
do {
# do test
do {
my $req = req(
REQUEST_METHOD => 'GET',
SCRIPT_NAME => '/',
);
is_deeply $req->cookies, {};
};
};