Commit | Line | Data |
50cc3183 |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
42da66a9 |
7 | use lib "$FindBin::Bin/../lib"; |
50cc3183 |
8 | |
9 | our $iters; |
10 | |
6b25e555 |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } |
50cc3183 |
12 | |
13 | use Test::More tests => 24*$iters; |
14 | use Catalyst::Test 'TestApp'; |
15 | |
16 | if ( $ENV{CAT_BENCHMARK} ) { |
17 | require Benchmark; |
18 | Benchmark::timethis( $iters, \&run_tests ); |
19 | } |
20 | else { |
21 | for ( 1 .. $iters ) { |
22 | run_tests(); |
23 | } |
24 | } |
25 | |
26 | sub run_tests { |
27 | { |
28 | ok( my $response = request('http://localhost/action/private/one'), |
29 | 'Request' ); |
30 | ok( $response->is_success, 'Response Successful 2xx' ); |
31 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
32 | is( |
33 | $response->header('X-Test-Class'), |
34 | 'TestApp::Controller::Action::Private', |
35 | 'Test Class' |
36 | ); |
37 | is( $response->content, 'access denied', 'Access' ); |
38 | } |
39 | |
40 | { |
41 | ok( my $response = request('http://localhost/action/private/two'), |
42 | 'Request' ); |
43 | ok( $response->is_success, 'Response Successful 2xx' ); |
44 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
45 | is( |
46 | $response->header('X-Test-Class'), |
47 | 'TestApp::Controller::Action::Private', |
48 | 'Test Class' |
49 | ); |
50 | is( $response->content, 'access denied', 'Access' ); |
51 | } |
52 | |
53 | { |
54 | ok( my $response = request('http://localhost/three'), 'Request' ); |
55 | ok( $response->is_error, 'Response Server Error 5xx' ); |
56 | is( $response->content_type, 'text/html', 'Response Content-Type' ); |
57 | like( |
58 | $response->header('X-Catalyst-Error'), |
59 | qr/^Unknown resource "three"/, |
60 | 'Catalyst Error' |
61 | ); |
62 | } |
63 | |
64 | { |
65 | ok( my $response = request('http://localhost/action/private/four'), |
66 | 'Request' ); |
67 | ok( $response->is_success, 'Response Successful 2xx' ); |
68 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
69 | is( |
70 | $response->header('X-Test-Class'), |
71 | 'TestApp::Controller::Action::Private', |
72 | 'Test Class' |
73 | ); |
74 | is( $response->content, 'access denied', 'Access' ); |
75 | } |
76 | |
77 | { |
78 | ok( my $response = request('http://localhost/action/private/five'), |
79 | 'Request' ); |
80 | ok( $response->is_success, 'Response Successful 2xx' ); |
81 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
82 | is( |
83 | $response->header('X-Test-Class'), |
84 | 'TestApp::Controller::Action::Private', |
85 | 'Test Class' |
86 | ); |
87 | is( $response->content, 'access denied', 'Access' ); |
88 | } |
89 | } |