9 eval { require Catalyst::Plugin::Session::State::Cookie }
11 "Catalyst::Plugin::Session::State::Cookie is required for this test";
13 eval { require Test::WWW::Mechanize::Catalyst }
15 "Test::WWW::Mechanize::Catalyst is required for this test";
21 use Test::WWW::Mechanize::Catalyst "SessionTestApp";
23 my $ua1 = Test::WWW::Mechanize::Catalyst->new;
24 my $ua2 = Test::WWW::Mechanize::Catalyst->new;
26 $_->get_ok("http://localhost/page", "initial get") for $ua1, $ua2;
28 $ua1->content_contains( "please login", "ua1 not logged in" );
29 $ua2->content_contains( "please login", "ua2 not logged in" );
31 $ua1->get_ok("http://localhost/login", "log ua1 in");
32 $ua1->content_contains( "logged in", "ua1 logged in" );
34 $_->get_ok("http://localhost/page", "get main page") for $ua1, $ua2;
36 $ua1->content_contains( "you are logged in", "ua1 logged in" );
37 $ua2->content_contains( "please login", "ua2 not logged in" );
39 $ua2->get_ok("http://localhost/login", "get main page");
40 $ua2->content_contains( "logged in", "log ua2 in" );
42 $_->get_ok("http://localhost/page", "get main page") for $ua1, $ua2;
44 $ua1->content_contains( "you are logged in", "ua1 logged in" );
45 $ua2->content_contains( "you are logged in", "ua2 logged in" );
47 $ua2->get_ok("http://localhost/logout", "log ua2 out");
48 $ua2->content_like( qr/logged out/, "ua2 logged out" );
49 $ua2->content_like( qr/after 1 request/, "ua2 made 1 request for page in the session" );
51 $_->get_ok("http://localhost/page", "get main page") for $ua1, $ua2;
53 $ua1->content_contains( "you are logged in", "ua1 logged in" );
54 $ua2->content_contains( "please login", "ua2 not logged in" );
56 $ua1->get_ok("http://localhost/logout", "log ua1 out");
57 $ua1->content_like( qr/logged out/, "ua1 logged out" );
58 $ua1->content_like( qr/after 3 requests/, "ua1 made 3 request for page in the session" );
60 $_->get_ok("http://localhost/page", "get main page") for $ua1, $ua2;
62 $ua1->content_contains( "please login", "ua1 not logged in" );
63 $ua2->content_contains( "please login", "ua2 not logged in" );