8 local $Data::Dumper::Sortkeys = 1;
12 require Catalyst::Plugin::Session::State::Cookie;
13 Catalyst::Plugin::Session::State::Cookie->VERSION(0.03);
16 "Catalyst::Plugin::Session::State::Cookie 0.03 or higher is required for this test";
18 eval { require Test::WWW::Mechanize::Catalyst }
20 "Test::WWW::Mechanize::Catalyst is required for this test";
26 use Test::WWW::Mechanize::Catalyst "SessionTestApp";
28 my $ua1 = Test::WWW::Mechanize::Catalyst->new;
29 my $ua2 = Test::WWW::Mechanize::Catalyst->new;
31 $_->get_ok( "http://localhost/page", "initial get" ) for $ua1, $ua2;
33 $ua1->content_contains( "please login", "ua1 not logged in" );
34 $ua2->content_contains( "please login", "ua2 not logged in" );
36 $_->get_ok( "http://localhost/inspect_session", "check for value in session" )
39 $ua1->content_contains( "value of logged_in is 'undef'",
40 "check ua1 'logged_in' val" );
41 $ua2->content_contains( "value of logged_in is 'undef'",
42 "check ua2 'logged_in' val" );
44 $_->get_ok( "http://localhost/page", "initial get" ) for $ua1, $ua2;
46 $ua1->content_contains( "please login", "ua1 not logged in" );
47 $ua2->content_contains( "please login", "ua2 not logged in" );
49 $ua1->get_ok( "http://localhost/login", "log ua1 in" );
50 $ua1->content_contains( "logged in", "ua1 logged in" );
52 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
54 $ua1->content_contains( "you are logged in", "ua1 logged in" );
55 $ua2->content_contains( "please login", "ua2 not logged in" );
57 $ua2->get_ok( "http://localhost/login", "get main page" );
58 $ua2->content_contains( "logged in", "log ua2 in" );
60 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
62 $ua1->content_contains( "you are logged in", "ua1 logged in" );
63 $ua2->content_contains( "you are logged in", "ua2 logged in" );
65 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
66 $ua1->content_contains( "you are logged in", "ua1 logged in" );
67 $ua2->content_contains( "you are logged in", "ua2 logged in" );
69 $ua2->get_ok( "http://localhost/logout", "log ua2 out" );
70 $ua2->content_like( qr/logged out/, "ua2 logged out" );
71 $ua2->content_like( qr/after 2 request/,
72 "ua2 made 2 requests for page in the session" );
74 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
76 $ua1->content_contains( "you are logged in", "ua1 logged in" );
77 $ua2->content_contains( "please login", "ua2 not logged in" );
79 $ua1->get_ok( "http://localhost/logout", "log ua1 out" );
80 $ua1->content_like( qr/logged out/, "ua1 logged out" );
81 $ua1->content_like( qr/after 4 requests/,
82 "ua1 made 4 request for page in the session" );
84 $_->get_ok( "http://localhost/page", "get main page" ) for $ua1, $ua2;
86 $ua1->content_contains( "please login", "ua1 not logged in" );
87 $ua2->content_contains( "please login", "ua2 not logged in" );