#!perl
use
lib
"$FindBin::Bin/lib"
;
our
$iters
;
BEGIN {
$iters
=
$ENV
{CAT_BENCH_ITERS} || 2; }
if
(
$ENV
{CAT_BENCHMARK} ) {
Benchmark::timethis(
$iters
, \
&run_tests
);
}
else
{
for
( 1 ..
$iters
) {
run_tests();
}
}
sub
run_tests {
{
my
@expected
=
qw[
TestApp::Controller::Action::Forward->begin
TestApp::Controller::Action::Forward->one
TestApp::Controller::Action::Forward->two
TestApp::Controller::Action::Forward->three
TestApp::Controller::Action::Forward->four
TestApp::Controller::Action::Forward->five
TestApp::View::Dump::Request->process
TestApp->end
]
;
my
$expected
=
join
(
", "
,
@expected
);
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/forward/global'
,
'Main Class Action'
);
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/forward/one'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Forward'
,
'Test Class'
);
is(
$response
->header(
'X-Catalyst-Executed'
),
$expected
,
'Executed actions'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
{
my
@expected
=
qw[
TestApp::Controller::Action::Forward->begin
TestApp::Controller::Action::Forward->jojo
TestApp::Controller::Action::Forward->one
TestApp::Controller::Action::Forward->two
TestApp::Controller::Action::Forward->three
TestApp::Controller::Action::Forward->four
TestApp::Controller::Action::Forward->five
TestApp::View::Dump::Request->process
TestApp::Controller::Action::Forward->three
TestApp::Controller::Action::Forward->four
TestApp::Controller::Action::Forward->five
TestApp::View::Dump::Request->process
TestApp->end
]
;
my
$expected
=
join
(
", "
,
@expected
);
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/forward/jojo'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Forward'
,
'Test Class'
);
is(
$response
->header(
'X-Catalyst-Executed'
),
$expected
,
'Executed actions'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
{
ok(
my
$response
=
'Request with args'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content,
'old'
);
}
{
ok(
my
$response
= request(
'Request with args and method'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content,
'old'
);
}
{
ok(
my
$response
=
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content,
'ok'
);
}
{
ok(
my
$response
=
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content,
'ok'
);
}
{
my
@expected
=
qw[
TestApp::Controller::Action::Relative->begin
TestApp::Controller::Action::Relative->relative
TestApp::Controller::Action::Forward->one
TestApp::Controller::Action::Forward->two
TestApp::Controller::Action::Forward->three
TestApp::Controller::Action::Forward->four
TestApp::Controller::Action::Forward->five
TestApp::View::Dump::Request->process
TestApp->end
]
;
my
$expected
=
join
(
", "
,
@expected
);
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->content_type,
'text/plain'
,
'Response Content-Type'
);
is(
$response
->header(
'X-Catalyst-Action'
),
'action/relative/relative'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Relative'
,
'Test Class'
);
is(
$response
->header(
'X-Catalyst-Executed'
),
$expected
,
'Executed actions'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
{
my
@expected
=
qw[
TestApp::Controller::Action::Relative->begin
TestApp::Controller::Action::Relative->relative_two
TestApp::Controller::Action::Forward->one
TestApp::Controller::Action::Forward->two
TestApp::Controller::Action::Forward->three
TestApp::Controller::Action::Forward->four
TestApp::Controller::Action::Forward->five
TestApp::View::Dump::Request->process
TestApp->end
]
;
my
$expected
=
join
(
", "
,
@expected
);
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/relative/relative_two'
,
'Test Action'
);
is(
$response
->header(
'X-Test-Class'
),
'TestApp::Controller::Action::Relative'
,
'Test Class'
);
is(
$response
->header(
'X-Catalyst-Executed'
),
$expected
,
'Executed actions'
);
like(
$response
->content,
qr/^bless\( .* 'Catalyst::Request' \)$/
s,
'Content is a serialized Catalyst::Request'
);
}
{
ok(
my
$response
= request(
'Request'
);
ok(
$response
->is_success,
'Response Successful 2xx'
);
is(
$response
->header(
'X-Class-Forward-Test-Method'
), 1,
'Test Method'
);
}
}