use
lib
"$FindBin::Bin/../lib"
;
our
$iters
;
BEGIN {
$iters
=
$ENV
{CAT_BENCH_ITERS} || 1; }
if
(
$ENV
{CAT_BENCHMARK} ) {
Benchmark::timethis(
$iters
, \
&run_tests
);
}
else
{
for
( 1 ..
$iters
) {
run_tests();
}
}
sub
run_tests {
{
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/local/one'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Local'
,
'Test Class'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
{
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/local/two'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Local'
,
'Test Class'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
{
'Request'
);
ok( !
$response
->is_success,
'Request with wrong number of args failed'
);
}
{
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/local/three'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Local'
,
'Test Class'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
{
ok(
my
$response
=
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/local/four/five/six'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Local'
,
'Test Class'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
SKIP:
{
if
(
$ENV
{CATALYST_SERVER} ) {
skip
"tests for %2F on remote server"
, 6;
}
ok(
my
$response
=
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/local/one'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Local'
,
'Test Class'
);
my
$content
=
$response
->content;
{
local
$@;
my
$request
=
eval
$content
;
if
($@) {
fail(
"Content cannot be unserialized: $@ $content"
);
}
else
{
is_deeply
$request
->arguments, [
'foo/bar'
],
"Parameters don't split on %2F"
;
}
}
}
{
'request with URI-encoded arg'
);
like(
$content
,
qr{'foo/bar;'}
,
'args for Local actions URI-decoded'
);
}
}