CGI-Application-Plugin-Session
view release on metacpan or search on metacpan
t/12_badconfig.t view on Meta::CPAN
use lib './t';
use Test::More;
BEGIN {
eval { require Test::Exception; Test::Exception->import; };
if ( $@ ) {
plan skip_all => 'These tests require Test::Exception';
}
else {
plan tests => 3;
}
};
{
package TestAppBadConfig;
@TestAppBadConfig::ISA = qw(CGI::Application);
use CGI::Application::Plugin::Session;
};
my $app = TestAppBadConfig->new();
$app->session_config( CGI_SESSION_OPTIONS => [ "driver:invalid_driver", $app->query ] );
dies_ok(sub { $app->session }, 'creation of CGI::Session object fails with a bad config');
## sub our own testing warn handler
my $warning;
$SIG{'__WARN__'} = sub { $warning = join ' ', @_ };
## mismatch cookie name and session name
my $app2 = TestAppBadConfig->new();
$app2->session_config(
CGI_SESSION_OPTIONS => [
"driver:File", '1111', {}, { name => 'foobar' }
],
COOKIE_PARAMS => { -name => 'monkeybeard' }
);
## should generate warning
$app2->session;
ok $warning, "cookie and session name don't match";
like $warning, qr/Cookie.*?Session/;
1;
( run in 0.517 second using v1.01-cache-2.11-cpan-e1769b4cff6 )