Commit | Line | Data |
e79a686c |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | |
8 | BEGIN { |
9 | eval { require Catalyst::Plugin::Session::State::Cookie; Catalyst::Plugin::Session::State::Cookie->VERSION(0.03) } |
10 | or plan skip_all => |
11 | "Catalyst::Plugin::Session::State::Cookie 0.03 or higher is required for this test"; |
12 | |
f8f81744 |
13 | eval { |
14 | require Test::WWW::Mechanize::Catalyst; |
15 | Test::WWW::Mechanize::Catalyst->VERSION(0.51); |
16 | } |
17 | or plan skip_all => |
18 | 'Test::WWW::Mechanize::Catalyst >= 0.51 is required for this test'; |
e79a686c |
19 | |
20 | plan tests => 12; |
21 | } |
22 | |
23 | use lib "t/lib"; |
24 | use Test::WWW::Mechanize::Catalyst "SessionTestApp"; |
25 | |
26 | my $ua = Test::WWW::Mechanize::Catalyst->new( { agent => 'Initial user_agent'} ); |
27 | $ua->get_ok( "http://localhost/user_agent", "get initial user_agent" ); |
28 | $ua->content_contains( "UA=Initial user_agent", "test initial user_agent" ); |
29 | |
30 | $ua->get_ok( "http://localhost/page", "initial get main page" ); |
31 | $ua->content_contains( "please login", "ua not logged in" ); |
32 | |
33 | $ua->get_ok( "http://localhost/login", "log ua in" ); |
34 | $ua->content_contains( "logged in", "ua logged in" ); |
35 | |
36 | $ua->get_ok( "http://localhost/page", "get main page" ); |
37 | $ua->content_contains( "you are logged in", "ua logged in" ); |
38 | |
39 | $ua->agent('Changed user_agent'); |
40 | $ua->get_ok( "http://localhost/user_agent", "get changed user_agent" ); |
41 | $ua->content_contains( "UA=Changed user_agent", "test changed user_agent" ); |
42 | |
43 | $ua->get_ok( "http://localhost/page", "test deleted session" ); |
44 | $ua->content_contains( "please login", "ua not logged in" ); |