- Fixed CAT_BENCH_ITERS :)
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / private.t
CommitLineData
dd4e6fd2 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
9770ad56 7use lib "$FindBin::Bin/../../../lib";
dd4e6fd2 8
232fd394 9our $iters;
10
11BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
12
13use Test::More tests => 24*$iters;
dd4e6fd2 14use Catalyst::Test 'TestApp';
15
232fd394 16if ( $ENV{CAT_BENCHMARK} ) {
17 require Benchmark;
5a6c7ff6 18 Benchmark::timethis( $iters, \&run_tests );
232fd394 19}
20else {
21 for ( 1 .. $iters ) {
22 run_tests();
23 }
24}
25
26sub run_tests {
d8c66af5 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 }
dd4e6fd2 39
d8c66af5 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 }
dd4e6fd2 52
d8c66af5 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 }
dd4e6fd2 63
d8c66af5 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 }
dd4e6fd2 76
d8c66af5 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 }
dd4e6fd2 89}