require specific ver of Test::WWW::Mechanize::Catalyst for t/live_app. remove some...
[catagits/Catalyst-Plugin-Session-State-Cookie.git] / t / live_app.t
index ac1fc59..9ef202e 100644 (file)
@@ -10,6 +10,7 @@ BEGIN {
     plan skip_all =>
       "This test requires Test::WWW::Mechanize::Catalyst in order to run"
       if $@;
+    plan skip_all => 'Test::WWW::Mechanize::Catalyst >= 0.40 required' if $Test::WWW::Mechanize::Catalyst::VERSION < 0.40;
     plan 'no_plan';
 }
 
@@ -34,6 +35,14 @@ BEGIN {
         $c->res->write($count);
     }
 
+    sub deleteme : Local {
+        my ( $self, $c ) = @_;
+        my $id = $c->get_session_id;
+        $c->delete_session;
+        my $id2 = $c->get_session_id;
+        $c->res->body( $id ne ( $id2 || '' ) );
+    }
+
     __PACKAGE__->setup;
 }
 
@@ -41,24 +50,27 @@ use Test::WWW::Mechanize::Catalyst qw/CookieTestApp/;
 
 my $m = Test::WWW::Mechanize::Catalyst->new;
 
-$m->get_ok( "http://foo.com/stream", "get page" );
+$m->get_ok( "http://localhost/stream", "get page" );
 $m->content_contains( "hit number 1", "session data created" );
 
 my $expired;
-$m->cookie_jar->scan( sub { $expired = $_[8] } );
+$m->cookie_jar->scan( sub { $expired = $_[8]; } );
 
-$m->get_ok( "http://foo.com/page", "get page" );
+$m->get_ok( "http://localhost/page", "get page" );
 $m->content_contains( "hit number 2", "session data restored" );
 
-$m->get_ok( "http://foo.com/stream", "get stream" );
+$m->get_ok( "http://localhost/stream", "get stream" );
 $m->content_contains( "hit number 3", "session data restored" );
 
-sleep 2;
+sleep 1;
 
-$m->get_ok( "http://foo.com/page", "get stream" );
+$m->get_ok( "http://localhost/page", "get stream" );
 $m->content_contains( "hit number 4", "session data restored" );
 
 my $updated_expired;
-$m->cookie_jar->scan( sub { $updated_expired = $_[8] } );
+$m->cookie_jar->scan( sub { $updated_expired = $_[8]; } );
 
 cmp_ok( $expired, "<", $updated_expired, "cookie expiration was extended" );
+
+$m->get_ok( "http://localhost/deleteme", "get page" );
+$m->content_is( 1, 'session id changed' );