Added recursive -r flag to prove example
[catagits/Catalyst-Runtime.git] / t / component / controller / action / inheritance.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 =>21;
10 use Catalyst::Test 'TestApp';
11
12
13 {
14     my @expected = qw[
15         TestApp::Controller::Action::Inheritance->begin
16         TestApp::Controller::Action::Inheritance->auto
17         TestApp::Controller::Action::Inheritance->default
18         TestApp::View::Dump::Request->process
19         TestApp::Controller::Action::Inheritance->end
20     ];
21
22     my $expected = join( ", ", @expected );
23
24     ok( my $response = request('http://localhost/action/inheritance'), 'Request' );
25     ok( $response->is_success, 'Response Successful 2xx' );
26     is( $response->content_type, 'text/plain', 'Response Content-Type' );
27     is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
28     is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance', 'Test Class' );
29     is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
30     like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
31 }
32
33 {
34     my @expected = qw[
35         TestApp::Controller::Action::Inheritance::A->begin
36         TestApp::Controller::Action::Inheritance->auto 
37         TestApp::Controller::Action::Inheritance::A->auto       
38         TestApp::Controller::Action::Inheritance::A->default
39         TestApp::View::Dump::Request->process
40         TestApp::Controller::Action::Inheritance::A->end
41     ];
42
43     my $expected = join( ", ", @expected );
44
45     ok( my $response = request('http://localhost/action/inheritance/a'), 'Request' );
46     ok( $response->is_success, 'Response Successful 2xx' );
47     is( $response->content_type, 'text/plain', 'Response Content-Type' );
48     is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
49     is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance::A', 'Test Class' );
50     is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
51     like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
52 }
53
54 {
55     my @expected = qw[
56         TestApp::Controller::Action::Inheritance::A::B->begin
57         TestApp::Controller::Action::Inheritance->auto 
58         TestApp::Controller::Action::Inheritance::A->auto
59         TestApp::Controller::Action::Inheritance::A::B->auto
60         TestApp::Controller::Action::Inheritance::A::B->default
61         TestApp::View::Dump::Request->process
62         TestApp::Controller::Action::Inheritance::A::B->end
63     ];
64
65     my $expected = join( ", ", @expected );
66
67     ok( my $response = request('http://localhost/action/inheritance/a/b'), 'Request' );
68     ok( $response->is_success, 'Response Successful 2xx' );
69     is( $response->content_type, 'text/plain', 'Response Content-Type' );
70     is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
71     is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance::A::B', 'Test Class' );
72     is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
73     like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
74 }