Change Catalsyt _parse_attrs so that when sub attr handlers:
[catagits/Catalyst-Runtime.git] / t / aggregate / live_component_controller_action_index.t
CommitLineData
50cc3183 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
42da66a9 7use lib "$FindBin::Bin/../lib";
50cc3183 8
9our $iters;
10
6b25e555 11BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
50cc3183 12
13use Test::More tests => 20*$iters;
14use Catalyst::Test 'TestApp';
15
16if ( $ENV{CAT_BENCHMARK} ) {
17 require Benchmark;
18 Benchmark::timethis( $iters, \&run_tests );
19}
20else {
21 for ( 1 .. $iters ) {
22 run_tests();
23 }
24}
25
26sub run_tests {
27 # test root index
28 {
29 my @expected = qw[
a0a66cb8 30 TestApp::Controller::Root->index
31 TestApp::Controller::Root->end
50cc3183 32 ];
b376e4ec 33
50cc3183 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' );
b376e4ec 39
50cc3183 40 ok( $response = request('http://localhost'), 'root index no slash' );
41 is( $response->content, 'root index', 'root index no slash ok' );
42 }
b376e4ec 43
50cc3183 44 # test first-level controller index
45 {
46 my @expected = qw[
47 TestApp::Controller::Index->index
a0a66cb8 48 TestApp::Controller::Root->end
50cc3183 49 ];
b376e4ec 50
50cc3183 51 my $expected = join( ", ", @expected );
b376e4ec 52
50cc3183 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' );
b376e4ec 57
50cc3183 58 ok( $response = request('http://localhost/index'), 'first-level controller index no slash' );
59 is( $response->header('X-Catalyst-Executed'),
60 $expected, 'Executed actions' );
b376e4ec 61 is( $response->content, 'Index index', 'first-level controller index no slash ok' );
62 }
63
50cc3183 64 # test second-level controller index
65 {
66 my @expected = qw[
67 TestApp::Controller::Action::Index->begin
68 TestApp::Controller::Action::Index->index
a0a66cb8 69 TestApp::Controller::Root->end
50cc3183 70 ];
b376e4ec 71
50cc3183 72 my $expected = join( ", ", @expected );
b376e4ec 73
50cc3183 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' );
b376e4ec 78
50cc3183 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' );
b376e4ec 82 is( $response->content, 'Action-Index index', 'second-level controller index no slash ok' );
50cc3183 83 }
b376e4ec 84
50cc3183 85 # test controller default when index is present
86 {
87 my @expected = qw[
88 TestApp::Controller::Action::Index->begin
89 TestApp::Controller::Action::Index->default
a0a66cb8 90 TestApp::Controller::Root->end
50cc3183 91 ];
b376e4ec 92
50cc3183 93 my $expected = join( ", ", @expected );
b376e4ec 94
50cc3183 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' );
99 }
100}