3fc9140d05e09cfb8e1781dee6525712e9b8a75b
[catagits/Catalyst-Runtime.git] / t / live_component_controller_action_childof.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin;
7 use lib "$FindBin::Bin/lib";
8
9 our $iters;
10
11 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
12
13 use Test::More tests => 9*$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         my @expected = qw[
29           TestApp::Controller::Action::ChildOf->begin
30           TestApp::Controller::Action::ChildOf->foo
31           TestApp::Controller::Action::ChildOf->endpoint
32           TestApp::Controller::Action::ChildOf->end
33         ];
34     
35         my $expected = join( ", ", @expected );
36     
37         ok( my $response = request('http://localhost/childof/foo/1/end/2'), 'childof + local endpoint' );
38         is( $response->header('X-Catalyst-Executed'),
39             $expected, 'Executed actions' );
40         is( $response->content, '1; 2', 'Content OK' );
41     }
42     {
43         my @expected = qw[
44           TestApp::Controller::Action::ChildOf->begin
45           TestApp::Controller::Action::ChildOf->foo
46           TestApp::Controller::Action::ChildOf::Foo->spoon
47           TestApp::Controller::Action::ChildOf->end
48         ];
49     
50         my $expected = join( ", ", @expected );
51     
52         ok( my $response = request('http://localhost/childof/foo/1/spoon'), 'childof + subcontroller endpoint' );
53         is( $response->header('X-Catalyst-Executed'),
54             $expected, 'Executed actions' );
55         is( $response->content, '1; ', 'Content OK' );
56     }
57     {
58         my @expected = qw[
59           TestApp::Controller::Action::ChildOf->begin
60           TestApp::Controller::Action::ChildOf->bar
61           TestApp::Controller::Action::ChildOf->finale
62           TestApp::Controller::Action::ChildOf->end
63         ];
64     
65         my $expected = join( ", ", @expected );
66     
67         ok( my $response = request('http://localhost/childof/bar/1/spoon'), 'childof + relative endpoint' );
68         is( $response->header('X-Catalyst-Executed'),
69             $expected, 'Executed actions' );
70         is( $response->content, '; 1, spoon', 'Content OK' );
71     }
72 }