Commit | Line | Data |
dd4e6fd2 |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
9770ad56 |
7 | use lib "$FindBin::Bin/../../../lib"; |
dd4e6fd2 |
8 | |
232fd394 |
9 | our $iters; |
10 | |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } |
12 | |
13 | use Test::More tests => 30*$iters; |
dd4e6fd2 |
14 | use Catalyst::Test 'TestApp'; |
15 | |
232fd394 |
16 | if ( $ENV{CAT_BENCHMARK} ) { |
17 | require Benchmark; |
5a6c7ff6 |
18 | Benchmark::timethis( $iters, \&run_tests ); |
232fd394 |
19 | } |
20 | else { |
21 | for ( 1 .. $iters ) { |
22 | run_tests(); |
23 | } |
24 | } |
25 | |
26 | sub run_tests { |
d8c66af5 |
27 | { |
28 | my @expected = qw[ |
29 | TestApp::Controller::Action::Forward->begin |
30 | TestApp::Controller::Action::Forward->one |
31 | TestApp::Controller::Action::Forward->two |
32 | TestApp::Controller::Action::Forward->three |
33 | TestApp::Controller::Action::Forward->four |
34 | TestApp::Controller::Action::Forward->five |
35 | TestApp::View::Dump::Request->process |
36 | ]; |
dd4e6fd2 |
37 | |
d8c66af5 |
38 | my $expected = join( ", ", @expected ); |
dd4e6fd2 |
39 | |
d8c66af5 |
40 | # Test forward to global private action |
41 | ok( my $response = request('http://localhost/action/forward/global'), |
42 | 'Request' ); |
43 | ok( $response->is_success, 'Response Successful 2xx' ); |
44 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
45 | is( $response->header('X-Catalyst-Action'), |
46 | 'action/forward/global', 'Main Class Action' ); |
40392ee9 |
47 | |
d8c66af5 |
48 | # Test forward to chain of actions. |
49 | ok( $response = request('http://localhost/action/forward/one'), |
50 | 'Request' ); |
51 | ok( $response->is_success, 'Response Successful 2xx' ); |
52 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
53 | is( $response->header('X-Catalyst-Action'), |
54 | 'action/forward/one', 'Test Action' ); |
55 | is( |
56 | $response->header('X-Test-Class'), |
57 | 'TestApp::Controller::Action::Forward', |
58 | 'Test Class' |
59 | ); |
60 | is( $response->header('X-Catalyst-Executed'), |
61 | $expected, 'Executed actions' ); |
62 | like( |
63 | $response->content, |
64 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
65 | 'Content is a serialized Catalyst::Request' |
66 | ); |
67 | } |
dd4e6fd2 |
68 | |
d8c66af5 |
69 | { |
70 | my @expected = qw[ |
71 | TestApp::Controller::Action::Forward->begin |
72 | TestApp::Controller::Action::Forward->jojo |
73 | TestApp::Controller::Action::Forward->one |
74 | TestApp::Controller::Action::Forward->two |
75 | TestApp::Controller::Action::Forward->three |
76 | TestApp::Controller::Action::Forward->four |
77 | TestApp::Controller::Action::Forward->five |
78 | TestApp::View::Dump::Request->process |
79 | TestApp::Controller::Action::Forward->three |
80 | TestApp::Controller::Action::Forward->four |
81 | TestApp::Controller::Action::Forward->five |
82 | TestApp::View::Dump::Request->process |
83 | ]; |
dd4e6fd2 |
84 | |
d8c66af5 |
85 | my $expected = join( ", ", @expected ); |
dd4e6fd2 |
86 | |
d8c66af5 |
87 | ok( my $response = request('http://localhost/action/forward/jojo'), |
88 | 'Request' ); |
89 | ok( $response->is_success, 'Response Successful 2xx' ); |
90 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
91 | is( $response->header('X-Catalyst-Action'), |
92 | 'action/forward/jojo', 'Test Action' ); |
93 | is( |
94 | $response->header('X-Test-Class'), |
95 | 'TestApp::Controller::Action::Forward', |
96 | 'Test Class' |
97 | ); |
98 | is( $response->header('X-Catalyst-Executed'), |
99 | $expected, 'Executed actions' ); |
100 | like( |
101 | $response->content, |
102 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
103 | 'Content is a serialized Catalyst::Request' |
104 | ); |
105 | } |
a1dad9c1 |
106 | |
d8c66af5 |
107 | { |
108 | ok( |
109 | my $response = |
110 | request('http://localhost/action/forward/with_args/old'), |
111 | 'Request with args' |
112 | ); |
113 | ok( $response->is_success, 'Response Successful 2xx' ); |
114 | is( $response->content, 'old' ); |
115 | } |
a1dad9c1 |
116 | |
d8c66af5 |
117 | { |
118 | ok( |
119 | my $response = request( |
120 | 'http://localhost/action/forward/with_method_and_args/old'), |
121 | 'Request with args and method' |
122 | ); |
123 | ok( $response->is_success, 'Response Successful 2xx' ); |
124 | is( $response->content, 'old' ); |
125 | } |
ab96c27a |
126 | |
d8c66af5 |
127 | # test forward with embedded args |
128 | { |
129 | ok( |
130 | my $response = |
131 | request('http://localhost/action/forward/args_embed_relative'), |
132 | 'Request' |
133 | ); |
134 | ok( $response->is_success, 'Response Successful 2xx' ); |
135 | is( $response->content, 'ok' ); |
136 | } |
40392ee9 |
137 | |
d8c66af5 |
138 | { |
139 | ok( |
140 | my $response = |
141 | request('http://localhost/action/forward/args_embed_absolute'), |
142 | 'Request' |
143 | ); |
144 | ok( $response->is_success, 'Response Successful 2xx' ); |
145 | is( $response->content, 'ok' ); |
146 | } |
a1dad9c1 |
147 | } |