Moved some PAR stuff
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / regexp.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 => 12*$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/regexp/10/hello'),
29 'Request' );
30 ok( $response->is_success, 'Response Successful 2xx' );
31 is( $response->content_type, 'text/plain', 'Response Content-Type' );
32 is( $response->header('X-Catalyst-Action'),
33 '^action/regexp/(\d+)/(\w+)$', 'Test Action' );
34 is(
35 $response->header('X-Test-Class'),
36 'TestApp::Controller::Action::Regexp',
37 'Test Class'
38 );
39 like(
40 $response->content,
41 qr/^bless\( .* 'Catalyst::Request' \)$/s,
42 'Content is a serialized Catalyst::Request'
43 );
44 }
dd4e6fd2 45
d8c66af5 46 {
47 ok( my $response = request('http://localhost/action/regexp/hello/10'),
48 'Request' );
49 ok( $response->is_success, 'Response Successful 2xx' );
50 is( $response->content_type, 'text/plain', 'Response Content-Type' );
51 is( $response->header('X-Catalyst-Action'),
52 '^action/regexp/(\w+)/(\d+)$', 'Test Action' );
53 is(
54 $response->header('X-Test-Class'),
55 'TestApp::Controller::Action::Regexp',
56 'Test Class'
57 );
58 like(
59 $response->content,
60 qr/^bless\( .* 'Catalyst::Request' \)$/s,
61 'Content is a serialized Catalyst::Request'
62 );
63 }
dd4e6fd2 64}