Commit | Line | Data |
141459fa |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/lib"; |
8 | |
9 | our $iters; |
10 | |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } |
12 | |
922c58d6 |
13 | use Test::More tests => 27*$iters; |
141459fa |
14 | use Catalyst::Test 'TestApp'; |
15 | |
16 | if ( $ENV{CAT_BENCHMARK} ) { |
17 | require Benchmark; |
18 | Benchmark::timethis( $iters, \&run_tests ); |
19 | } |
20 | else { |
21 | for ( 1 .. $iters ) { |
22 | run_tests(); |
23 | } |
24 | } |
922c58d6 |
25 | |
141459fa |
26 | sub run_tests { |
27 | { |
28 | my @expected = qw[ |
29 | TestApp::Controller::Action::ChildOf->begin |
30 | TestApp::Controller::Action::ChildOf->foo |
31 | TestApp::Controller::Action::ChildOf->endpoint |
a7edfd93 |
32 | TestApp::Controller::Action::ChildOf->end |
141459fa |
33 | ]; |
922c58d6 |
34 | |
141459fa |
35 | my $expected = join( ", ", @expected ); |
922c58d6 |
36 | |
141459fa |
37 | ok( my $response = request('http://localhost/childof/foo/1/end/2'), 'childof + local endpoint' ); |
38 | is( $response->header('X-Catalyst-Executed'), |
39 | $expected, 'Executed actions' ); |
40 | is( $response->content, '1; 2', 'Content OK' ); |
41 | } |
42 | { |
43 | my @expected = qw[ |
44 | TestApp::Controller::Action::ChildOf->begin |
45 | TestApp::Controller::Action::ChildOf->foo |
46 | TestApp::Controller::Action::ChildOf::Foo->spoon |
a7edfd93 |
47 | TestApp::Controller::Action::ChildOf->end |
141459fa |
48 | ]; |
922c58d6 |
49 | |
141459fa |
50 | my $expected = join( ", ", @expected ); |
922c58d6 |
51 | |
141459fa |
52 | ok( my $response = request('http://localhost/childof/foo/1/spoon'), 'childof + subcontroller endpoint' ); |
53 | is( $response->header('X-Catalyst-Executed'), |
54 | $expected, 'Executed actions' ); |
55 | is( $response->content, '1; ', 'Content OK' ); |
56 | } |
57 | { |
58 | my @expected = qw[ |
59 | TestApp::Controller::Action::ChildOf->begin |
60 | TestApp::Controller::Action::ChildOf->bar |
61 | TestApp::Controller::Action::ChildOf->finale |
a7edfd93 |
62 | TestApp::Controller::Action::ChildOf->end |
141459fa |
63 | ]; |
922c58d6 |
64 | |
141459fa |
65 | my $expected = join( ", ", @expected ); |
922c58d6 |
66 | |
141459fa |
67 | ok( my $response = request('http://localhost/childof/bar/1/spoon'), 'childof + relative endpoint' ); |
68 | is( $response->header('X-Catalyst-Executed'), |
69 | $expected, 'Executed actions' ); |
70 | is( $response->content, '; 1, spoon', 'Content OK' ); |
71 | } |
922c58d6 |
72 | { |
73 | my @expected = qw[ |
74 | TestApp::Controller::Action::ChildOf->begin |
75 | TestApp::Controller::Action::ChildOf->foo2 |
76 | TestApp::Controller::Action::ChildOf->endpoint2 |
77 | TestApp::Controller::Action::ChildOf->end |
78 | ]; |
79 | |
80 | my $expected = join( ", ", @expected ); |
81 | |
82 | ok( my $response = request('http://localhost/childof/foo2/10/20/end2/15/25'), |
83 | 'childof + local (2 args each)' ); |
84 | is( $response->header('X-Catalyst-Executed'), |
85 | $expected, 'Executed actions' ); |
86 | is( $response->content, '10, 20; 15, 25', 'Content OK' ); |
87 | } |
88 | { |
89 | my @expected = qw[ |
90 | TestApp::Controller::Action::ChildOf->begin |
91 | TestApp::Controller::Action::ChildOf->one_end |
92 | TestApp::Controller::Action::ChildOf->end |
93 | ]; |
94 | |
95 | my $expected = join( ", ", @expected ); |
96 | |
97 | ok( my $response = request('http://localhost/childof/one/23'), |
98 | 'three-chain (only first)' ); |
99 | is( $response->header('X-Catalyst-Executed'), |
100 | $expected, 'Executed actions' ); |
101 | is( $response->content, '; 23', 'Content OK' ); |
102 | } |
103 | { |
104 | my @expected = qw[ |
105 | TestApp::Controller::Action::ChildOf->begin |
106 | TestApp::Controller::Action::ChildOf->one |
107 | TestApp::Controller::Action::ChildOf->two_end |
108 | TestApp::Controller::Action::ChildOf->end |
109 | ]; |
110 | |
111 | my $expected = join( ", ", @expected ); |
112 | |
113 | ok( my $response = request('http://localhost/childof/one/23/two/23/46'), |
114 | 'three-chain (up to second)' ); |
115 | is( $response->header('X-Catalyst-Executed'), |
116 | $expected, 'Executed actions' ); |
117 | is( $response->content, '23; 23, 46', 'Content OK' ); |
118 | } |
119 | { |
120 | my @expected = qw[ |
121 | TestApp::Controller::Action::ChildOf->begin |
122 | TestApp::Controller::Action::ChildOf->one |
123 | TestApp::Controller::Action::ChildOf->two |
124 | TestApp::Controller::Action::ChildOf->three_end |
125 | TestApp::Controller::Action::ChildOf->end |
126 | ]; |
127 | |
128 | my $expected = join( ", ", @expected ); |
129 | |
130 | ok( my $response = request('http://localhost/childof/one/23/two/23/46/three/1/2/3'), |
131 | 'three-chain (all three)' ); |
132 | is( $response->header('X-Catalyst-Executed'), |
133 | $expected, 'Executed actions' ); |
134 | is( $response->content, '23, 23, 46; 1, 2, 3', 'Content OK' ); |
135 | } |
136 | { |
137 | my @expected = qw[ |
138 | TestApp::Controller::Action::ChildOf->begin |
139 | TestApp::Controller::Action::ChildOf->multi1 |
140 | TestApp::Controller::Action::ChildOf->end |
141 | ]; |
142 | |
143 | my $expected = join( ", ", @expected ); |
144 | |
145 | ok( my $response = request('http://localhost/childof/multi/23'), |
146 | 'multi-action (one arg)' ); |
147 | is( $response->header('X-Catalyst-Executed'), |
148 | $expected, 'Executed actions' ); |
149 | is( $response->content, '; 23', 'Content OK' ); |
150 | } |
151 | { |
152 | my @expected = qw[ |
153 | TestApp::Controller::Action::ChildOf->begin |
154 | TestApp::Controller::Action::ChildOf->multi2 |
155 | TestApp::Controller::Action::ChildOf->end |
156 | ]; |
157 | |
158 | my $expected = join( ", ", @expected ); |
159 | |
160 | ok( my $response = request('http://localhost/childof/multi/23/46'), |
161 | 'multi-action (two args)' ); |
162 | is( $response->header('X-Catalyst-Executed'), |
163 | $expected, 'Executed actions' ); |
164 | is( $response->content, '; 23, 46', 'Content OK' ); |
165 | } |
141459fa |
166 | } |