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