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