NAME

Test::Mojo::Role::Session - Testing session in Mojolicious applications

SYNOPSIS

use Mojolicious::Lite;
use Test::More;
use Test::Mojo::WithRoles 'Session';

get '/set' => sub {
  my $c = shift;
  $c->session(s1 => 'session data');
  $c->session(s3 => [1, 3]);
  $c->render(text => 's1');
} => 'set';

my $t = Test::Mojo::WithRoles->new;
$t->get_ok('/set')
  ->status_is(200)
  ->session_ok
  ->session_has('/s1')
  ->session_is('/s1' => 'session data')
  ->session_hasnt('/s2')
  ->session_is('/s3' => [1, 3])
  ->session_like('/s1' => qr/data/, 's1 contains "data"')
  ->session_unlike('/s1' => qr/foo/, 's1 does not contain "foo"');

done_testing();

DESCRIPTION

Test::Mojo::Role::Session is an role for the Test::Mojo::WithRoles, which allows you to conveniently test session in Mojolicious applications.

METHODS

Test::Mojo::Role::Sesssion has the same methods as Test::Mojo::Session.

SEE ALSO

Test::Mojo::WithRoles.