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;
27 sub start_session : Local {
28 my ( $self, $c ) = @_;
29 $c->session->{counter} = 1;
30 $c->res->body($c->stash->{_session}->{id});
34 my ( $self, $c, $id ) = @_;
35 $c->stash ( '_session' => {id => $id} );
36 $c->res->body( "Hi! hit number " . ++$c->session->{counter} );
40 my ( $self, $c, $id ) = @_;
41 $c->stash ( '_session' => {id => $id} );
42 my $count = ++$c->session->{counter};
43 $c->res->body("hit number $count");
46 sub deleteme : Local {
47 my ( $self, $c, $id ) = @_;
48 $c->stash ( '_session' => {id => $id} );
49 my $id2 = $c->get_session_id;
51 my $id3 = $c->get_session_id;
53 # In the success case, print 'Pass'
58 $c->res->body('PASS');
60 #In the failure case, provide debug info
62 $c->res->body("FAIL: Matching ids, $id3");
69 use Test::WWW::Mechanize::Catalyst qw/TestApp/;
71 my $m = Test::WWW::Mechanize::Catalyst->new;
73 #Number of tests to run. A begin block every 10 will ensure the count is correct
77 $m->get_ok( "http://localhost/start_session", "get page" );
78 my $session = uri_escape($m->content);
80 $m->get_ok( "http://localhost/page/$session", "get page" );
81 $m->content_contains( "hit number 2", "session data restored" );
83 $m->get_ok( "http://localhost/stream/$session", "get stream" );
84 $m->content_contains( "hit number 3", "session data restored" );
86 BEGIN { $tests += 5; }
88 $m->get_ok( "http://localhost/stream/$session", "get page" );
89 $m->content_contains( "hit number 4", "session data restored" );
90 $m->get_ok( "http://localhost/deleteme/$session", "get page" );
93 local $TODO = "Changing sessions is broken and I've had no success fixing it. Patches welcome";
94 $m->content_is( 'PASS' , 'session id changed' );
96 BEGIN { $tests += 4; }