5 use lib "$FindBin::Bin/../lib";
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
11 use Test::More tests => 16 * $iters;
12 use Catalyst::Test 'TestApp';
14 if ( $ENV{CAT_BENCHMARK} ) {
16 Benchmark::timethis( $iters, \&run_tests );
27 TestApp::Controller::Action::Default->begin
28 TestApp::Controller::Action::Default->default
29 TestApp::View::Dump::Request->process
30 TestApp::Controller::Root->end
33 my $expected = join( ", ", @expected );
35 ok( my $response = request('http://localhost/action/default'),
37 ok( $response->is_success, 'Response Successful 2xx' );
38 is( $response->content_type, 'text/plain', 'Response Content-Type' );
39 is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
41 $response->header('X-Test-Class'),
42 'TestApp::Controller::Action::Default',
45 is( $response->header('X-Catalyst-Executed'),
46 $expected, 'Executed actions' );
49 qr/^bless\( .* 'Catalyst::Request' \)$/s,
50 'Content is a serialized Catalyst::Request'
53 ok( $response = request('http://localhost/foo/bar/action'), 'Request' );
54 is( $response->code, 500, 'Invalid URI returned 500' );
57 # test that args are passed properly to default
60 my $expected = [qw/action default arg1 arg2/];
62 ok( my $response = request('http://localhost/action/default/arg1/arg2'),
65 eval '$creq = ' . $response->content,
66 'Unserialize Catalyst::Request'
67 ) or fail("EXCEPTION $@ DESERIALIZING " . $response->content);
68 is_deeply( $creq->{arguments}, $expected, 'Arguments ok' );
72 # Test that /foo and /foo/ both do the same thing
75 TestApp::Controller::Action->begin
76 TestApp::Controller::Action->default
77 TestApp::Controller::Root->end
80 my $expected = join( ", ", @expected );
82 ok( my $response = request('http://localhost/action'), 'Request' );
83 is( $response->header('X-Catalyst-Executed'),
85 'Executed actions for /action'
88 ok( $response = request('http://localhost/action/'), 'Request' );
89 is( $response->header('X-Catalyst-Executed'),
91 'Executed actions for /action/'