5 use lib "$FindBin::Bin/../lib";
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
12 use Catalyst::Test 'TestApp';
14 if ( $ENV{CAT_BENCHMARK} ) {
16 Benchmark::timethis( $iters, \&run_tests );
19 # 11 wallclock secs (10.14 usr + 0.20 sys = 10.34 CPU) @ 15.18/s (n=157)
20 # old dispatcher (r1486):
21 # 11 wallclock secs (10.34 usr + 0.20 sys = 10.54 CPU) @ 13.76/s (n=145)
30 # test auto + local method
33 TestApp::Controller::Action::Auto->begin
34 TestApp::Controller::Action::Auto->auto
35 TestApp::Controller::Action::Auto->one
36 TestApp::Controller::Root->end
39 my $expected = join( ", ", @expected );
41 ok( my $response = request('http://localhost/action/auto/one'), 'auto + local' );
42 is( $response->header('X-Catalyst-Executed'),
43 $expected, 'Executed actions' );
44 is( $response->content, 'one', 'Content OK' );
50 TestApp::Controller::Action::Auto->begin
51 TestApp::Controller::Action::Auto->auto
52 TestApp::Controller::Action::Auto->default
53 TestApp::Controller::Root->end
56 my $expected = join( ", ", @expected );
58 ok( my $response = request('http://localhost/action/auto/anything'), 'auto + default' );
59 is( $response->header('X-Catalyst-Executed'),
60 $expected, 'Executed actions' );
61 is( $response->content, 'default', 'Content OK' );
64 # test auto + auto + local
67 TestApp::Controller::Action::Auto::Deep->begin
68 TestApp::Controller::Action::Auto->auto
69 TestApp::Controller::Action::Auto::Deep->auto
70 TestApp::Controller::Action::Auto::Deep->one
71 TestApp::Controller::Root->end
74 my $expected = join( ", ", @expected );
76 ok( my $response = request('http://localhost/action/auto/deep/one'), 'auto + auto + local' );
77 is( $response->header('X-Catalyst-Executed'),
78 $expected, 'Executed actions' );
79 is( $response->content, 'deep one', 'Content OK' );
82 # test auto + auto + default
85 TestApp::Controller::Action::Auto::Deep->begin
86 TestApp::Controller::Action::Auto->auto
87 TestApp::Controller::Action::Auto::Deep->auto
88 TestApp::Controller::Action::Auto::Deep->default
89 TestApp::Controller::Root->end
92 my $expected = join( ", ", @expected );
94 ok( my $response = request('http://localhost/action/auto/deep/anything'), 'auto + auto + default' );
95 is( $response->header('X-Catalyst-Executed'),
96 $expected, 'Executed actions' );
97 is( $response->content, 'deep default', 'Content OK' );
100 # test auto + failing auto + local + end
103 TestApp::Controller::Action::Auto::Abort->begin
104 TestApp::Controller::Action::Auto->auto
105 TestApp::Controller::Action::Auto::Abort->auto
106 TestApp::Controller::Action::Auto::Abort->end
109 my $expected = join( ", ", @expected );
111 ok( my $response = request('http://localhost/action/auto/abort/one'), 'auto + failing auto + local' );
112 is( $response->header('X-Catalyst-Executed'),
113 $expected, 'Executed actions' );
114 is( $response->content, 'abort end', 'Content OK' );
117 # test auto + default (bug on invocation of default twice)
120 TestApp::Controller::Action::Auto::Default->begin
121 TestApp::Controller::Action::Auto->auto
122 TestApp::Controller::Action::Auto::Default->auto
123 TestApp::Controller::Action::Auto::Default->default
124 TestApp::Controller::Action::Auto::Default->end
127 my $expected = join( ", ", @expected );
129 ok( my $response = request('http://localhost/action/auto/default/moose'), 'auto + default' );
130 is( $response->header('X-Catalyst-Executed'),
131 $expected, 'Executed actions' );
132 is( $response->content, 'default (auto: 1)', 'Content OK' );
135 # test detach in auto
138 TestApp::Controller::Action::Auto::Detach->begin
139 TestApp::Controller::Action::Auto->auto
140 TestApp::Controller::Action::Auto::Detach->auto
141 TestApp::Controller::Root->end
144 my $expected = join( ", ", @expected );
146 ok( my $response = request('http://localhost/action/auto/detach'), 'auto with detach' );
147 is( $response->header('X-Catalyst-Executed'),
148 $expected, 'Executed actions' );
149 is( $response->content, 'detach auto', 'Content OK' );
152 # test detach in auto forward
155 TestApp::Controller::Action::Auto::Detach->begin
156 TestApp::Controller::Action::Auto->auto
157 TestApp::Controller::Action::Auto::Detach->auto
158 TestApp::Controller::Action::Auto::Detach->with_forward_detach
159 TestApp::Controller::Root->end
162 my $expected = join( ", ", @expected );
164 ok( my $response = request('http://localhost/action/auto/detach?with_forward_detach=1'), 'auto with_forward_detach' );
165 is( $response->header('X-Catalyst-Executed'),
166 $expected, 'Executed actions' );
167 is( $response->content, 'detach with_forward_detach', 'Content OK' );
170 # test detach in auto forward detach action
173 TestApp::Controller::Action::Auto::Detach->begin
174 TestApp::Controller::Action::Auto->auto
175 TestApp::Controller::Action::Auto::Detach->auto
176 TestApp::Controller::Action::Auto::Detach->with_forward_detach
177 TestApp::Controller::Action::Auto::Detach->detach_action
178 TestApp::Controller::Root->end
181 my $expected = join( ", ", @expected );
183 ok( my $response = request('http://localhost/action/auto/detach?with_forward_detach=1&detach_to_action=1'), 'auto with_forward_detach to detach_action' );
184 is( $response->header('X-Catalyst-Executed'),
185 $expected, 'Executed actions' );
186 is( $response->content, 'detach_action', 'Content OK' );