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