7 use lib "$FindBin::Bin/../../../lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
13 use Test::More tests => 19*$iters;
14 use Catalyst::Test 'TestApp';
16 if ( $ENV{CAT_BENCHMARK} ) {
18 Benchmark::timethis( $iters, \&run_tests );
29 ok( my $response = request('http://localhost/'), 'root index' );
30 is( $response->content, 'root index', 'root index ok' );
32 ok( $response = request('http://localhost'), 'root index no slash' );
33 is( $response->content, 'root index', 'root index no slash ok' );
36 # test first-level controller index
39 TestApp::Controller::Index->index
42 my $expected = join( ", ", @expected );
44 ok( my $response = request('http://localhost/index/'), 'first-level controller index' );
45 is( $response->header('X-Catalyst-Executed'),
46 $expected, 'Executed actions' );
47 is( $response->content, 'Index index', 'first-level controller index ok' );
49 ok( $response = request('http://localhost/index'), 'first-level controller index no slash' );
50 is( $response->header('X-Catalyst-Executed'),
51 $expected, 'Executed actions' );
52 is( $response->content, 'Index index', 'first-level controller index no slash ok' );
55 # test second-level controller index
58 TestApp::Controller::Action::Index->begin
59 TestApp::Controller::Action::Index->index
62 my $expected = join( ", ", @expected );
64 ok( my $response = request('http://localhost/action/index/'), 'second-level controller index' );
65 is( $response->header('X-Catalyst-Executed'),
66 $expected, 'Executed actions' );
67 is( $response->content, 'Action-Index index', 'second-level controller index ok' );
69 ok( $response = request('http://localhost/action/index'), 'second-level controller index no slash' );
70 is( $response->header('X-Catalyst-Executed'),
71 $expected, 'Executed actions' );
72 is( $response->content, 'Action-Index index', 'second-level controller index no slash ok' );
75 # test controller default when index is present
78 TestApp::Controller::Action::Index->begin
79 TestApp::Controller::Action::Index->default
82 my $expected = join( ", ", @expected );
84 ok( my $response = request('http://localhost/action/index/foo'), 'default with index' );
85 is( $response->header('X-Catalyst-Executed'),
86 $expected, 'Executed actions' );
87 is( $response->content, "Error - TestApp::Controller::Action\n", 'default with index ok' );