12 eval { require Test::WWW::Mechanize::Catalyst };
14 "This test requires Test::WWW::Mechanize::Catalyst in order to run"
16 plan skip_all => 'Test::WWW::Mechanize::Catalyst >= 0.40 required' if $Test::WWW::Mechanize::Catalyst::VERSION < 0.40;
20 use Test::WWW::Mechanize::Catalyst qw/CookieTestApp/;
22 my $m = Test::WWW::Mechanize::Catalyst->new;
24 $m->get_ok( "http://localhost/stream", "get page" );
25 $m->content_contains( "hit number 1", "session data created" );
28 $m->cookie_jar->scan( sub { $expired = $_[8]; } );
30 $m->get_ok( "http://localhost/page", "get page" );
31 $m->content_contains( "hit number 2", "session data restored" );
33 $m->get_ok( "http://localhost/stream", "get stream" );
34 $m->content_contains( "hit number 3", "session data restored" );
38 $m->get_ok( "http://localhost/stream", "get page" );
39 $m->content_contains( "hit number 4", "session data restored" );
42 $m->cookie_jar->scan( sub { $updated_expired = $_[8]; } );
43 cmp_ok( $expired, "<", $updated_expired, "cookie expiration was extended" );
45 $expired = $m->cookie_jar->scan( sub { $expired = $_[8] } );
46 $m->get_ok( "http://localhost/page", "get page again");
47 $m->content_contains( "hit number 5", "session data restored (blah)" );
51 $m->get_ok( "http://localhost/stream", "get stream" );
52 $m->content_contains( "hit number 6", "session data restored" );
54 $m->cookie_jar->scan( sub { $updated_expired = $_[8]; } );
55 cmp_ok( $expired, "<", $updated_expired, "streaming also extends cookie" );
57 $m->get_ok( "http://localhost/deleteme", "get page" );
58 $m->content_is( 1, 'session id changed' );