Added some stress testing
[catagits/Catalyst-Runtime.git] / t / live / 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 => 210;
10 use Catalyst::Test 'TestApp';
11
12 for ( 1 .. 10 ) {
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'),
25             'Request' );
26         ok( $response->is_success, 'Response Successful 2xx' );
27         is( $response->content_type, 'text/plain', 'Response Content-Type' );
28         is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
29         is(
30             $response->header('X-Test-Class'),
31             'TestApp::Controller::Action::Inheritance',
32             'Test Class'
33         );
34         is( $response->header('X-Catalyst-Executed'),
35             $expected, 'Executed actions' );
36         like(
37             $response->content,
38             qr/^bless\( .* 'Catalyst::Request' \)$/s,
39             'Content is a serialized Catalyst::Request'
40         );
41     }
42
43     {
44         my @expected = qw[
45           TestApp::Controller::Action::Inheritance::A->begin
46           TestApp::Controller::Action::Inheritance->auto
47           TestApp::Controller::Action::Inheritance::A->auto
48           TestApp::Controller::Action::Inheritance::A->default
49           TestApp::View::Dump::Request->process
50           TestApp::Controller::Action::Inheritance::A->end
51         ];
52
53         my $expected = join( ", ", @expected );
54
55         ok( my $response = request('http://localhost/action/inheritance/a'),
56             'Request' );
57         ok( $response->is_success, 'Response Successful 2xx' );
58         is( $response->content_type, 'text/plain', 'Response Content-Type' );
59         is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
60         is(
61             $response->header('X-Test-Class'),
62             'TestApp::Controller::Action::Inheritance::A',
63             'Test Class'
64         );
65         is( $response->header('X-Catalyst-Executed'),
66             $expected, 'Executed actions' );
67         like(
68             $response->content,
69             qr/^bless\( .* 'Catalyst::Request' \)$/s,
70             'Content is a serialized Catalyst::Request'
71         );
72     }
73
74     {
75         my @expected = qw[
76           TestApp::Controller::Action::Inheritance::A::B->begin
77           TestApp::Controller::Action::Inheritance->auto
78           TestApp::Controller::Action::Inheritance::A->auto
79           TestApp::Controller::Action::Inheritance::A::B->auto
80           TestApp::Controller::Action::Inheritance::A::B->default
81           TestApp::View::Dump::Request->process
82           TestApp::Controller::Action::Inheritance::A::B->end
83         ];
84
85         my $expected = join( ", ", @expected );
86
87         ok( my $response = request('http://localhost/action/inheritance/a/b'),
88             'Request' );
89         ok( $response->is_success, 'Response Successful 2xx' );
90         is( $response->content_type, 'text/plain', 'Response Content-Type' );
91         is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
92         is(
93             $response->header('X-Test-Class'),
94             'TestApp::Controller::Action::Inheritance::A::B',
95             'Test Class'
96         );
97         is( $response->header('X-Catalyst-Executed'),
98             $expected, 'Executed actions' );
99         like(
100             $response->content,
101             qr/^bless\( .* 'Catalyst::Request' \)$/s,
102             'Content is a serialized Catalyst::Request'
103         );
104     }
105 }