Added recursive -r flag to prove example
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / forward.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin;
7 use lib "$FindBin::Bin/../../../lib";
8
9 use Test::More tests => 24;
10 use Catalyst::Test 'TestApp';
11
12
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     ];
23
24     my $expected = join( ", ", @expected );
25
26    # Test forward to global private action
27     ok( my $response = request('http://localhost/action/forward/global'), 'Request' );
28     ok( $response->is_success, 'Response Successful 2xx' );
29     is( $response->content_type, 'text/plain', 'Response Content-Type' );
30     is( $response->header('X-Catalyst-Action'), 'action/forward/global', 'Main Class Action' );
31     # Test forward to chain of actions.
32     ok( $response = request('http://localhost/action/forward/one'), 'Request' );
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[
43         TestApp::Controller::Action::Forward->begin
44         TestApp::Controller::Action::Forward->jojo
45         TestApp::Controller::Action::Forward->one
46         TestApp::Controller::Action::Forward->two
47         TestApp::Controller::Action::Forward->three
48         TestApp::Controller::Action::Forward->four
49         TestApp::Controller::Action::Forward->five
50         TestApp::View::Dump::Request->process
51         TestApp::Controller::Action::Forward->three
52         TestApp::Controller::Action::Forward->four
53         TestApp::Controller::Action::Forward->five
54         TestApp::View::Dump::Request->process
55     ];
56
57     my $expected = join( ", ", @expected );
58
59     ok( my $response = request('http://localhost/action/forward/jojo'), 'Request' );
60     ok( $response->is_success, 'Response Successful 2xx' );
61     is( $response->content_type, 'text/plain', 'Response Content-Type' );
62     is( $response->header('X-Catalyst-Action'), 'action/forward/jojo', 'Test Action' );
63     is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Forward', 'Test Class' );
64     is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
65     like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
66 }
67
68 {
69     ok( my $response = request('http://localhost/action/forward/with_args/old'), 'Request with args' );
70     ok( $response->is_success, 'Response Successful 2xx' );
71     is( $response->content,'old');
72 }
73
74 {
75     ok( my $response = request('http://localhost/action/forward/with_method_and_args/old'), 'Request with args and method' );
76     ok( $response->is_success, 'Response Successful 2xx' );
77     is( $response->content,'old');
78 }