use inlined module hiding in tests
[catagits/Catalyst-Runtime.git] / t / aggregate / live_component_controller_action_global.t
1 use strict;
2 use warnings;
3
4 use FindBin;
5 use lib "$FindBin::Bin/../lib";
6
7 our $iters;
8
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
10
11 use Test::More tests => 18*$iters;
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         ok( my $response = request('http://localhost/action_global_one'),
27             'Request' );
28         ok( $response->is_success, 'Response Successful 2xx' );
29         is( $response->content_type, 'text/plain', 'Response Content-Type' );
30         is( $response->header('X-Catalyst-Action'),
31             'action_global_one', 'Test Action' );
32         is(
33             $response->header('X-Test-Class'),
34             'TestApp::Controller::Action::Global',
35             'Test Class'
36         );
37         like(
38             $response->content,
39             qr/^bless\( .* 'Catalyst::Request' \)$/s,
40             'Content is a serialized Catalyst::Request'
41         );
42     }
43
44     {
45         ok( my $response = request('http://localhost/action_global_two'),
46             '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'),
50             'action_global_two', 'Test Action' );
51         is(
52             $response->header('X-Test-Class'),
53             'TestApp::Controller::Action::Global',
54             'Test Class'
55         );
56         like(
57             $response->content,
58             qr/^bless\( .* 'Catalyst::Request' \)$/s,
59             'Content is a serialized Catalyst::Request'
60         );
61     }
62
63     {
64         ok( my $response = request('http://localhost/action_global_three'),
65             'Request' );
66         ok( $response->is_success, 'Response Successful 2xx' );
67         is( $response->content_type, 'text/plain', 'Response Content-Type' );
68         is( $response->header('X-Catalyst-Action'),
69             'action_global_three', 'Test Action' );
70         is(
71             $response->header('X-Test-Class'),
72             'TestApp::Controller::Action::Global',
73             'Test Class'
74         );
75         like(
76             $response->content,
77             qr/^bless\( .* 'Catalyst::Request' \)$/s,
78             'Content is a serialized Catalyst::Request'
79         );
80     }
81 }