7 use lib "$FindBin::Bin/../lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
13 use Test::More tests => 16 * $iters;
14 use Catalyst::Test 'TestApp';
16 if ( $ENV{CAT_BENCHMARK} ) {
18 Benchmark::timethis( $iters, \&run_tests );
29 TestApp::Controller::Action::Default->begin
30 TestApp::Controller::Action::Default->default
31 TestApp::View::Dump::Request->process
32 TestApp::Controller::Root->end
35 my $expected = join( ", ", @expected );
37 ok( my $response = request('http://localhost/action/default'),
39 ok( $response->is_success, 'Response Successful 2xx' );
40 is( $response->content_type, 'text/plain', 'Response Content-Type' );
41 is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
43 $response->header('X-Test-Class'),
44 'TestApp::Controller::Action::Default',
47 is( $response->header('X-Catalyst-Executed'),
48 $expected, 'Executed actions' );
51 qr/^bless\( .* 'Catalyst::Request' \)$/s,
52 'Content is a serialized Catalyst::Request'
55 ok( $response = request('http://localhost/foo/bar/action'), 'Request' );
56 is( $response->code, 500, 'Invalid URI returned 500' );
59 # test that args are passed properly to default
62 my $expected = [qw/action default arg1 arg2/];
64 ok( my $response = request('http://localhost/action/default/arg1/arg2'),
67 eval '$creq = ' . $response->content,
68 'Unserialize Catalyst::Request'
69 ) or fail("EXCEPTION $@ DESERIALIZING " . $response->content);
70 is_deeply( $creq->{arguments}, $expected, 'Arguments ok' );
74 # Test that /foo and /foo/ both do the same thing
77 TestApp::Controller::Action->begin
78 TestApp::Controller::Action->default
79 TestApp::Controller::Root->end
82 my $expected = join( ", ", @expected );
84 ok( my $response = request('http://localhost/action'), 'Request' );
85 is( $response->header('X-Catalyst-Executed'),
87 'Executed actions for /action'
90 ok( $response = request('http://localhost/action/'), 'Request' );
91 is( $response->header('X-Catalyst-Executed'),
93 'Executed actions for /action/'