diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-07-18 16:22:08 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-07-18 16:22:08 -0500 |
commit | b5d66ba6e274eed251da951bb943b9ff67765290 (patch) | |
tree | 8b468f4ec6279a2d218f44d69a530c2a2476f1fc /t/cookie.t | |
parent | bc67313aa7191255f4123ae8d89f890e2f0772bc (diff) | |
download | web-request-b5d66ba6e274eed251da951bb943b9ff67765290.tar.gz web-request-b5d66ba6e274eed251da951bb943b9ff67765290.zip |
import the Plack::Request test suite
Diffstat (limited to 't/cookie.t')
-rw-r--r-- | t/cookie.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/t/cookie.t b/t/cookie.t new file mode 100644 index 0000000..b32b2d0 --- /dev/null +++ b/t/cookie.t @@ -0,0 +1,59 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Plack::Test; + +use HTTP::Request; +use Web::Request; + +my $app = sub { + my $req = Web::Request->new_from_env(shift); + + is $req->cookies->{undef}, undef; + is $req->cookies->{Foo}, 'Bar'; + is $req->cookies->{Bar}, 'Baz'; + is $req->cookies->{XXX}, 'Foo Bar'; + is $req->cookies->{YYY}, 0; + + $req->new_response(status => 200)->finalize; +}; + +test_psgi $app, sub { + my $cb = shift; + my $req = HTTP::Request->new(GET => "/"); + $req->header(Cookie => 'Foo=Bar; Bar=Baz; XXX=Foo%20Bar; YYY=0; YYY=3'); + $cb->($req); +}; + +$app = sub { + my $req = Web::Request->new_from_env(shift); + is_deeply $req->cookies, {}; + $req->new_response(status => 200)->finalize; +}; + +test_psgi $app, sub { + my $cb = shift; + $cb->(HTTP::Request->new(GET => "/")); +}; + +$app = sub { + my $warn = 0; + local $SIG{__WARN__} = sub { $warn++ }; + + my $req = Web::Request->new_from_env(shift); + + is $req->cookies->{Foo}, 'Bar'; + is $warn, 0; + + $req->new_response(status => 200)->finalize; +}; + +test_psgi $app, sub { + my $cb = shift; + my $req = HTTP::Request->new(GET => "/"); + $req->header(Cookie => 'Foo=Bar,; Bar=Baz;'); + $cb->($req); +}; + +done_testing; |