Commit | Line | Data |
50cc3183 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use FindBin; |
42da66a9 |
5 | use lib "$FindBin::Bin/../lib"; |
50cc3183 |
6 | |
7 | our $iters; |
8 | |
6b25e555 |
9 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } |
50cc3183 |
10 | |
f2572e63 |
11 | use Test::More tests => 21*$iters; |
50cc3183 |
12 | use Catalyst::Test 'TestApp'; |
13 | |
14 | if ( $ENV{CAT_BENCHMARK} ) { |
15 | require Benchmark; |
16 | Benchmark::timethis( $iters, \&run_tests ); |
17 | } |
18 | else { |
19 | for ( 1 .. $iters ) { |
20 | run_tests(); |
21 | } |
22 | } |
23 | |
24 | sub run_tests { |
25 | { |
26 | my @expected = qw[ |
27 | TestApp::Controller::Action::Inheritance->begin |
28 | TestApp::Controller::Action::Inheritance->auto |
29 | TestApp::Controller::Action::Inheritance->default |
30 | TestApp::View::Dump::Request->process |
31 | TestApp::Controller::Action::Inheritance->end |
32 | ]; |
33 | |
34 | my $expected = join( ", ", @expected ); |
35 | |
36 | ok( my $response = request('http://localhost/action/inheritance'), |
37 | 'Request' ); |
38 | ok( $response->is_success, 'Response Successful 2xx' ); |
39 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
40 | is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' ); |
41 | is( |
42 | $response->header('X-Test-Class'), |
43 | 'TestApp::Controller::Action::Inheritance', |
44 | 'Test Class' |
45 | ); |
46 | is( $response->header('X-Catalyst-Executed'), |
47 | $expected, 'Executed actions' ); |
48 | like( |
49 | $response->content, |
50 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
51 | 'Content is a serialized Catalyst::Request' |
52 | ); |
53 | } |
54 | |
55 | { |
56 | my @expected = qw[ |
57 | TestApp::Controller::Action::Inheritance::A->begin |
58 | TestApp::Controller::Action::Inheritance->auto |
59 | TestApp::Controller::Action::Inheritance::A->auto |
60 | TestApp::Controller::Action::Inheritance::A->default |
61 | TestApp::View::Dump::Request->process |
62 | TestApp::Controller::Action::Inheritance::A->end |
63 | ]; |
64 | |
65 | my $expected = join( ", ", @expected ); |
66 | |
67 | ok( my $response = request('http://localhost/action/inheritance/a'), |
68 | 'Request' ); |
69 | ok( $response->is_success, 'Response Successful 2xx' ); |
70 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
71 | is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' ); |
72 | is( |
73 | $response->header('X-Test-Class'), |
74 | 'TestApp::Controller::Action::Inheritance::A', |
75 | 'Test Class' |
76 | ); |
77 | is( $response->header('X-Catalyst-Executed'), |
78 | $expected, 'Executed actions' ); |
79 | like( |
80 | $response->content, |
81 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
82 | 'Content is a serialized Catalyst::Request' |
83 | ); |
84 | } |
85 | |
86 | { |
87 | my @expected = qw[ |
88 | TestApp::Controller::Action::Inheritance::A::B->begin |
89 | TestApp::Controller::Action::Inheritance->auto |
90 | TestApp::Controller::Action::Inheritance::A->auto |
91 | TestApp::Controller::Action::Inheritance::A::B->auto |
92 | TestApp::Controller::Action::Inheritance::A::B->default |
93 | TestApp::View::Dump::Request->process |
94 | TestApp::Controller::Action::Inheritance::A::B->end |
95 | ]; |
96 | |
97 | my $expected = join( ", ", @expected ); |
98 | |
99 | ok( my $response = request('http://localhost/action/inheritance/a/b'), |
100 | 'Request' ); |
101 | ok( $response->is_success, 'Response Successful 2xx' ); |
102 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
103 | is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' ); |
104 | is( |
105 | $response->header('X-Test-Class'), |
106 | 'TestApp::Controller::Action::Inheritance::A::B', |
107 | 'Test Class' |
108 | ); |
109 | is( $response->header('X-Catalyst-Executed'), |
110 | $expected, 'Executed actions' ); |
111 | like( |
112 | $response->content, |
113 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
114 | 'Content is a serialized Catalyst::Request' |
115 | ); |
116 | } |
117 | } |