fix objects that evaulate to false. rafl
[catagits/Catalyst-Runtime.git] / t / 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
a1c8f974 9use Test::More tests => 31;
dd4e6fd2 10use Catalyst::Test 'TestApp';
11
12
13{
14 my @expected = qw[
dd4e6fd2 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 ];
23
24 my $expected = join( ", ", @expected );
25
2656a6de 26 # Test forward to global private action
e5d7f18c 27 ok( my $response = request('http://localhost/action/forward/global'), 'Request' );
2656a6de 28 ok( $response->is_success, 'Response Successful 2xx' );
29 is( $response->content_type, 'text/plain', 'Response Content-Type' );
e5d7f18c 30 is( $response->header('X-Catalyst-Action'), 'action/forward/global', 'Main Class Action' );
2656a6de 31 # Test forward to chain of actions.
32 ok( $response = request('http://localhost/action/forward/one'), 'Request' );
dd4e6fd2 33 ok( $response->is_success, 'Response Successful 2xx' );
34 is( $response->content_type, 'text/plain', 'Response Content-Type' );
35 is( $response->header('X-Catalyst-Action'), 'action/forward/one', 'Test Action' );
36 is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Forward', 'Test Class' );
37 is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
38 like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
39}
40
41{
42 my @expected = qw[
dd4e6fd2 43 TestApp::Controller::Action::Forward->begin
a1c8f974 44 TestApp::Controller::Action::Forward->six
45 TestApp::View::Dump::False->process
46 ];
47
48 my $expected = join( ", ", @expected );
49
50 ok( my $response = request('http://localhost/action/forward/six'), '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'), 'action/forward/six', 'Main Class Action' );
54 is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Forward', 'Test Class' );
55 is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
56 like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
57}
58
59{
60 my @expected = qw[
61 TestApp::Controller::Action::Forward->begin
dd4e6fd2 62 TestApp::Controller::Action::Forward->jojo
63 TestApp::Controller::Action::Forward->one
64 TestApp::Controller::Action::Forward->two
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 TestApp::Controller::Action::Forward->three
70 TestApp::Controller::Action::Forward->four
71 TestApp::Controller::Action::Forward->five
72 TestApp::View::Dump::Request->process
73 ];
74
75 my $expected = join( ", ", @expected );
76
77 ok( my $response = request('http://localhost/action/forward/jojo'), 'Request' );
78 ok( $response->is_success, 'Response Successful 2xx' );
79 is( $response->content_type, 'text/plain', 'Response Content-Type' );
80 is( $response->header('X-Catalyst-Action'), 'action/forward/jojo', 'Test Action' );
81 is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Forward', 'Test Class' );
82 is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
83 like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
84}
a1dad9c1 85
86{
87 ok( my $response = request('http://localhost/action/forward/with_args/old'), 'Request with args' );
88 ok( $response->is_success, 'Response Successful 2xx' );
89 is( $response->content,'old');
90}
91
92{
93 ok( my $response = request('http://localhost/action/forward/with_method_and_args/old'), 'Request with args and method' );
94 ok( $response->is_success, 'Response Successful 2xx' );
95 is( $response->content,'old');
96}