5 use lib "$FindBin::Bin/../lib";
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
11 use Test::More tests => 20*$iters;
12 use Catalyst::Test 'TestApp';
14 if ( $ENV{CAT_BENCHMARK} ) {
16 Benchmark::timethis( $iters, \&run_tests );
28 TestApp::Controller::Root->index
29 TestApp::Controller::Root->end
32 my $expected = join( ", ", @expected );
33 ok( my $response = request('http://localhost/'), 'root index' );
34 is( $response->header('X-Catalyst-Executed'),
35 $expected, 'Executed actions' );
36 is( $response->content, 'root index', 'root index ok' );
38 ok( $response = request('http://localhost'), 'root index no slash' );
39 is( $response->content, 'root index', 'root index no slash ok' );
42 # test first-level controller index
45 TestApp::Controller::Index->index
46 TestApp::Controller::Root->end
49 my $expected = join( ", ", @expected );
51 ok( my $response = request('http://localhost/index/'), 'first-level controller index' );
52 is( $response->header('X-Catalyst-Executed'),
53 $expected, 'Executed actions' );
54 is( $response->content, 'Index index', 'first-level controller index ok' );
56 ok( $response = request('http://localhost/index'), 'first-level controller index no slash' );
57 is( $response->header('X-Catalyst-Executed'),
58 $expected, 'Executed actions' );
59 is( $response->content, 'Index index', 'first-level controller index no slash ok' );
62 # test second-level controller index
65 TestApp::Controller::Action::Index->begin
66 TestApp::Controller::Action::Index->index
67 TestApp::Controller::Root->end
70 my $expected = join( ", ", @expected );
72 ok( my $response = request('http://localhost/action/index/'), 'second-level controller index' );
73 is( $response->header('X-Catalyst-Executed'),
74 $expected, 'Executed actions' );
75 is( $response->content, 'Action-Index index', 'second-level controller index ok' );
77 ok( $response = request('http://localhost/action/index'), 'second-level controller index no slash' );
78 is( $response->header('X-Catalyst-Executed'),
79 $expected, 'Executed actions' );
80 is( $response->content, 'Action-Index index', 'second-level controller index no slash ok' );
83 # test controller default when index is present
86 TestApp::Controller::Action::Index->begin
87 TestApp::Controller::Action::Index->default
88 TestApp::Controller::Root->end
91 my $expected = join( ", ", @expected );
93 ok( my $response = request('http://localhost/action/index/foo'), 'default with index' );
94 is( $response->header('X-Catalyst-Executed'),
95 $expected, 'Executed actions' );
96 is( $response->content, "Error - TestApp::Controller::Action\n", 'default with index ok' );