CGI-Application
view release on metacpan or search on metacpan
# run() CGI::Application sub-class, in run mode 'cookie_test'.
# Expect HTTP header w/ cookie:
# 'c_name' => 'c_value' + 'Hello World: cookie_test'.
{
my $app = TestApp->new();
$app->query(CGI->new({'test_rm' => 'cookie_test'}));
response_like(
$app,
qr/^Set-Cookie: c_name=c_value/,
qr/Hello World: cookie_test/,
"TestApp, cookie test",
);
}
# run() CGI::Application sub-class, in run mode 'tmpl_test'.
# Expect HTTP header + 'Hello World: tmpl_test'.
{
my $app = TestApp->new(TMPL_PATH=>'t/lib/templates/');
unlike($output, qr/second-header: 1/, "no second-header header");
unlike($output, qr/Test2:/, "no Test2 header, either");
}
# testing header_add with arrayref
{
my $app = TestApp->new();
$app->query(CGI->new({'test_rm' => 'header_add_arrayref_test'}));
my $output = $app->run();
like($output, qr/Set-Cookie: cookie1=header_add/, "arrayref test: cookie1");
like($output, qr/Set-Cookie: cookie2=header_add/, "arrayref test: cookie2");
}
# make sure header_add does not clobber earlier headers
{
my $app = TestApp->new();
$app->query(CGI->new({'test_rm' => 'header_props_before_header_add'}));
my $output = $app->run();
like($output, qr/Set-Cookie: cookie1=header_props/, "header_props: cookie1");
like($output, qr/Set-Cookie: cookie2=header_add/, "header_add: cookie2");
}
# make sure header_add works after header_props is called
{
my $app = TestApp->new();
$app->query(CGI->new({'test_rm' => 'header_add_after_header_props'}));
my $output = $app->run();
like($output, qr/Set-Cookie: cookie2=header_add/, "header add after props");
}
# test use of TMPL_PATH without trailing slash
{
my $app = TestApp->new(TMPL_PATH=>'t/lib/templates');
$app->query(CGI->new({'test_rm' => 'tmpl_badparam_test'}));
response_like(
$app,
qr{^Content-Type: text/html},
( run in 0.391 second using v1.01-cache-2.11-cpan-e9199f4ba4c )