9 eval { require Test::WWW::Mechanize::Catalyst };
11 "This test requires Test::WWW::Mechanize::Catalyst in order to run"
18 package CookieTestApp;
22 Session::State::Cookie
26 my ( $self, $c ) = @_;
27 $c->res->body( "Hi! hit number " . ++$c->session->{counter} );
31 my ( $self, $c ) = @_;
32 my $count = ++$c->session->{counter};
33 $c->res->write("hit number ");
34 $c->res->write($count);
40 use Test::WWW::Mechanize::Catalyst qw/CookieTestApp/;
42 my $m = Test::WWW::Mechanize::Catalyst->new;
44 $m->get_ok( "http://foo.com/stream", "get page" );
45 $m->content_contains( "hit number 1", "session data created" );
48 $m->cookie_jar->scan( sub { $expired = $_[8] } );
50 $m->get_ok( "http://foo.com/page", "get page" );
51 $m->content_contains( "hit number 2", "session data restored" );
53 $m->get_ok( "http://foo.com/stream", "get stream" );
54 $m->content_contains( "hit number 3", "session data restored" );
58 $m->get_ok( "http://foo.com/page", "get stream" );
59 $m->content_contains( "hit number 4", "session data restored" );
62 $m->cookie_jar->scan( sub { $updated_expired = $_[8] } );
64 cmp_ok( $expired, "<", $updated_expired, "cookie expiration was extended" );