7 use lib "$FindBin::Bin/../lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
13 use Test::More tests => 20*$iters;
14 use Catalyst::Test 'TestApp';
16 if ( $ENV{CAT_BENCHMARK} ) {
18 Benchmark::timethis( $iters, \&run_tests );
30 TestApp::Controller::Root->index
31 TestApp::Controller::Root->end
34 my $expected = join( ", ", @expected );
35 ok( my $response = request('http://localhost/'), 'root index' );
36 is( $response->header('X-Catalyst-Executed'),
37 $expected, 'Executed actions' );
38 is( $response->content, 'root index', 'root index ok' );
40 ok( $response = request('http://localhost'), 'root index no slash' );
41 is( $response->content, 'root index', 'root index no slash ok' );
44 # test first-level controller index
47 TestApp::Controller::Index->index
48 TestApp::Controller::Root->end
51 my $expected = join( ", ", @expected );
53 ok( my $response = request('http://localhost/index/'), 'first-level controller index' );
54 is( $response->header('X-Catalyst-Executed'),
55 $expected, 'Executed actions' );
56 is( $response->content, 'Index index', 'first-level controller index ok' );
58 ok( $response = request('http://localhost/index'), 'first-level controller index no slash' );
59 is( $response->header('X-Catalyst-Executed'),
60 $expected, 'Executed actions' );
61 is( $response->content, 'Index index', 'first-level controller index no slash ok' );
64 # test second-level controller index
67 TestApp::Controller::Action::Index->begin
68 TestApp::Controller::Action::Index->index
69 TestApp::Controller::Root->end
72 my $expected = join( ", ", @expected );
74 ok( my $response = request('http://localhost/action/index/'), 'second-level controller index' );
75 is( $response->header('X-Catalyst-Executed'),
76 $expected, 'Executed actions' );
77 is( $response->content, 'Action-Index index', 'second-level controller index ok' );
79 ok( $response = request('http://localhost/action/index'), 'second-level controller index no slash' );
80 is( $response->header('X-Catalyst-Executed'),
81 $expected, 'Executed actions' );
82 is( $response->content, 'Action-Index index', 'second-level controller index no slash ok' );
85 # test controller default when index is present
88 TestApp::Controller::Action::Index->begin
89 TestApp::Controller::Action::Index->default
90 TestApp::Controller::Root->end
93 my $expected = join( ", ", @expected );
95 ok( my $response = request('http://localhost/action/index/foo'), 'default with index' );
96 is( $response->header('X-Catalyst-Executed'),
97 $expected, 'Executed actions' );
98 is( $response->content, "Error - TestApp::Controller::Action\n", 'default with index ok' );