new test suit
[catagits/Catalyst-Runtime.git] / t / 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 no_plan => 1;
10 use Catalyst::Test 'TestApp';
11
12
13 {
14     my @expected = qw[
15         TestApp::Controller::Action->begin
16         TestApp::Controller::Action::Inheritance->begin
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->begin
36         TestApp::Controller::Action::Inheritance->begin
37         TestApp::Controller::Action::Inheritance::A->begin
38         TestApp::Controller::Action::Inheritance::A->default
39         TestApp::View::Dump::Request->process
40         TestApp::Controller::Action::Inheritance::A->end
41         TestApp::Controller::Action::Inheritance->end
42     ];
43
44     my $expected = join( ", ", @expected );
45
46     ok( my $response = request('http://localhost/action/inheritance/a'), 'Request' );
47     ok( $response->is_success, 'Response Successful 2xx' );
48     is( $response->content_type, 'text/plain', 'Response Content-Type' );
49     is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
50     is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance::A', 'Test Class' );
51     is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
52     like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
53 }
54
55 {
56     my @expected = qw[
57         TestApp::Controller::Action->begin
58         TestApp::Controller::Action::Inheritance->begin
59         TestApp::Controller::Action::Inheritance::A->begin
60         TestApp::Controller::Action::Inheritance::A::B->begin
61         TestApp::Controller::Action::Inheritance::A::B->default
62         TestApp::View::Dump::Request->process
63         TestApp::Controller::Action::Inheritance::A::B->end
64         TestApp::Controller::Action::Inheritance::A->end
65         TestApp::Controller::Action::Inheritance->end
66     ];
67
68     my $expected = join( ", ", @expected );
69
70     ok( my $response = request('http://localhost/action/inheritance/a/b'), 'Request' );
71     ok( $response->is_success, 'Response Successful 2xx' );
72     is( $response->content_type, 'text/plain', 'Response Content-Type' );
73     is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
74     is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Inheritance::A::B', 'Test Class' );
75     is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );
76     like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
77 }