10 eval { require Test::WWW::Mechanize::Catalyst };
12 "This test requires Test::WWW::Mechanize::Catalyst in order to run"
14 plan skip_all => 'Test::WWW::Mechanize::Catalyst >= 0.40 required' if $Test::WWW::Mechanize::Catalyst::VERSION < 0.40;
18 use Test::WWW::Mechanize::Catalyst qw/CookieTestApp/;
20 my $m = Test::WWW::Mechanize::Catalyst->new;
22 $m->get_ok( "http://localhost/stream", "get page" );
23 $m->content_contains( "hit number 1", "session data created" );
26 $m->cookie_jar->scan( sub { $expired = $_[8]; } );
28 $m->get_ok( "http://localhost/page", "get page" );
29 $m->content_contains( "hit number 2", "session data restored" );
31 $m->get_ok( "http://localhost/stream", "get stream" );
32 $m->content_contains( "hit number 3", "session data restored" );
36 $m->get_ok( "http://localhost/stream", "get page" );
37 $m->content_contains( "hit number 4", "session data restored" );
40 $m->cookie_jar->scan( sub { $updated_expired = $_[8]; } );
41 cmp_ok( $expired, "<", $updated_expired, "cookie expiration was extended" );
43 $expired = $m->cookie_jar->scan( sub { $expired = $_[8] } );
44 $m->get_ok( "http://localhost/page", "get page again");
45 $m->content_contains( "hit number 5", "session data restored (blah)" );
49 $m->get_ok( "http://localhost/stream", "get stream" );
50 $m->content_contains( "hit number 6", "session data restored" );
52 $m->cookie_jar->scan( sub { $updated_expired = $_[8]; } );
53 cmp_ok( $expired, "<", $updated_expired, "streaming also extends cookie" );
55 $m->get_ok( "http://localhost/deleteme", "get page" );
56 $m->content_is( 1, 'session id changed' );
58 $m->get_ok( "https://localhost/page", "get page over HTTPS - init session");
59 $m->content_contains( "hit number 1", "first hit" );
60 $m->get_ok( "http://localhost/page", "get page again over HTTP");
61 $m->content_contains( "hit number 1", "first hit again - cookie not sent" );
62 $m->get_ok( "https://localhost/page", "get page over HTTPS");
63 $m->content_contains( "hit number 2", "second hit" );