X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F014_cookie_options.t;fp=t%2F014_cookie_options.t;h=007ac9642a66d3d07e6d0e03ea2d42f06e49682f;hb=442b79a8223a0e29b95035f5f47a8b78480cf6a2;hp=0000000000000000000000000000000000000000;hpb=ee51674d7247c5988d29d157068fa1aef2f515ca;p=catagits%2FWeb-Session.git diff --git a/t/014_cookie_options.t b/t/014_cookie_options.t new file mode 100644 index 0000000..007ac96 --- /dev/null +++ b/t/014_cookie_options.t @@ -0,0 +1,23 @@ +use strict; +use Test::More; + +my $time = 1264843167; +BEGIN { *CORE::GLOBAL::time = sub() { $time } } +use Plack::Session::State::Cookie; + +my $st = Plack::Session::State::Cookie->new; +$st->domain('.example.com'); +$st->secure(1); +$st->expires(3600); +$st->path('/cgi-bin'); + +is_deeply +{ $st->merge_options(id => 123) }, + { domain => '.example.com', secure => 1, expires => $time + 3600, path => '/cgi-bin' }; + +is_deeply +{ $st->merge_options(id => 123, path => '/', domain => '.perl.org') }, + { domain => '.perl.org', secure => 1, expires => $time + 3600, path => '/' }; + +is_deeply +{ $st->merge_options(id => 123, expires => $time + 1, secure => 0) }, + { domain => '.example.com', secure => 0, expires => $time + 1, path => '/cgi-bin' }; + +done_testing;