test inheritance of builtin actions in mainapp.
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / default.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 my @expected = qw[
29 TestApp::Controller::Action::Default->begin
30 TestApp::Controller::Action::Default->default
31 TestApp::View::Dump::Request->process
01ba879f 32 TestApp->end
d8c66af5 33 ];
34
35 my $expected = join( ", ", @expected );
36
37 ok( my $response = request('http://localhost/action/default'),
38 'Request' );
39 ok( $response->is_success, 'Response Successful 2xx' );
40 is( $response->content_type, 'text/plain', 'Response Content-Type' );
41 is( $response->header('X-Catalyst-Action'), 'default', 'Test Action' );
42 is(
43 $response->header('X-Test-Class'),
44 'TestApp::Controller::Action::Default',
45 'Test Class'
46 );
47 is( $response->header('X-Catalyst-Executed'),
48 $expected, 'Executed actions' );
49 like(
50 $response->content,
51 qr/^bless\( .* 'Catalyst::Request' \)$/s,
52 'Content is a serialized Catalyst::Request'
53 );
54
55 ok( $response = request('http://localhost/foo/bar/action'), 'Request' );
56 is( $response->code, 404, 'Invalid URI returned 404' );
57 }
746380d1 58
59 # test that args are passed properly to default
60 {
61 my $creq;
62 my $expected = [ qw/action default arg1 arg2/ ];
63
64 ok( my $response = request('http://localhost/action/default/arg1/arg2'), 'Request' );
65 ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
66 is_deeply( $creq->{arguments}, $expected, 'Arguments ok' );
67 }
dd4e6fd2 68}