1#!perl
2
3BEGIN {
4  unless ($ENV{AUTHOR_TESTING}) {
5    require Test::More;
6    Test::More::plan(skip_all => 'these tests are for testing by the author');
7  }
8}
9
10
11use strict;
12use warnings;
13
14use FindBin;
15use lib "$FindBin::Bin/lib";
16
17our $iters;
18
19BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
20
21use Test::More tests => 7*$iters;
22use Catalyst::Test 'TestApp';
23
24if ( $ENV{CAT_BENCHMARK} ) {
25    require Benchmark;
26    Benchmark::timethis( $iters, \&run_tests );
27}
28else {
29    for ( 1 .. $iters ) {
30        run_tests();
31    }
32}
33
34sub run_tests {
35    {
36        my @expected = qw[
37          TestApp::Controller::Action::End->begin
38          TestApp::Controller::Action::End->default
39          TestApp::View::Dump::Request->process
40          TestApp::Controller::Action::End->end
41        ];
42
43        my $expected = join( ", ", @expected );
44
45        ok( my $response = request('http://localhost/action/end'), 'Request' );
46        ok( $response->is_success, 'Response Successful 2xx' );
47        is( $response->content_type, 'text/plain', 'Response Content-Type' );
48        is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
49        is(
50            $response->header('X-Test-Class'),
51            'TestApp::Controller::Action::End',
52            'Test Class'
53        );
54        is( $response->header('X-Catalyst-Executed'),
55            $expected, 'Executed actions' );
56        like(
57            $response->content,
58            qr/^bless\( .* 'Catalyst::Request' \)$/s,
59            'Content is a serialized Catalyst::Request'
60        );
61    }
62}
63