remove session_class and psgix.session per discussion on IRC :)
[catagits/Web-Session.git] / t / 010_middleware.t
CommitLineData
fe1bfe7d 1use Plack::Test;
2use Plack::Middleware::Session;
3use Test::More;
4use HTTP::Request::Common;
5use HTTP::Cookies;
6
7my $app = sub {
8 my $env = shift;
c6a7260c 9 my $counter = $env->{'psgix.session'}->{counter} || 0;
fe1bfe7d 10
11 my $body = "Counter=$counter";
c6a7260c 12 $env->{'psgix.session'}->{counter} = $counter + 1;
fe1bfe7d 13
14 return [ 200, [], [ $body ] ];
15};
16
c6a7260c 17$app = Plack::Middleware::Session->wrap($app);
fe1bfe7d 18
19test_psgi $app, sub {
20 my $cb = shift;
21
22 my $jar = HTTP::Cookies->new;
23
24 my $res = $cb->(GET "http://localhost/");
25 is $res->content, "Counter=0";
26 $jar->extract_cookies($res);
27
28 my $req = GET "http://localhost/";
29 $jar->add_cookie_header($req);
fe1bfe7d 30 $res = $cb->($req);
31 is $res->content, "Counter=1";
32};
33
34done_testing;
35