7 use lib "$FindBin::Bin/lib";
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
13 use Test::More tests => 27*$iters;
14 use Catalyst::Test 'TestApp';
16 if ( $ENV{CAT_BENCHMARK} ) {
18 Benchmark::timethis( $iters, \&run_tests );
29 TestApp::Controller::Action::ChildOf->begin
30 TestApp::Controller::Action::ChildOf->foo
31 TestApp::Controller::Action::ChildOf->endpoint
32 TestApp::Controller::Action::ChildOf->end
35 my $expected = join( ", ", @expected );
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' );
44 TestApp::Controller::Action::ChildOf->begin
45 TestApp::Controller::Action::ChildOf->foo
46 TestApp::Controller::Action::ChildOf::Foo->spoon
47 TestApp::Controller::Action::ChildOf->end
50 my $expected = join( ", ", @expected );
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' );
59 TestApp::Controller::Action::ChildOf->begin
60 TestApp::Controller::Action::ChildOf->bar
61 TestApp::Controller::Action::ChildOf->finale
62 TestApp::Controller::Action::ChildOf->end
65 my $expected = join( ", ", @expected );
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' );
74 TestApp::Controller::Action::ChildOf->begin
75 TestApp::Controller::Action::ChildOf->foo2
76 TestApp::Controller::Action::ChildOf->endpoint2
77 TestApp::Controller::Action::ChildOf->end
80 my $expected = join( ", ", @expected );
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' );
90 TestApp::Controller::Action::ChildOf->begin
91 TestApp::Controller::Action::ChildOf->one_end
92 TestApp::Controller::Action::ChildOf->end
95 my $expected = join( ", ", @expected );
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' );
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
111 my $expected = join( ", ", @expected );
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' );
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
128 my $expected = join( ", ", @expected );
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' );
138 TestApp::Controller::Action::ChildOf->begin
139 TestApp::Controller::Action::ChildOf->multi1
140 TestApp::Controller::Action::ChildOf->end
143 my $expected = join( ", ", @expected );
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' );
153 TestApp::Controller::Action::ChildOf->begin
154 TestApp::Controller::Action::ChildOf->multi2
155 TestApp::Controller::Action::ChildOf->end
158 my $expected = join( ", ", @expected );
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' );