Merged 5.49_01 (r1339) from refactored branch to trunk
[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
fbcc39ad 9use Test::More tests => 24;
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
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}
a1dad9c1 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}