nuked tabs
[catagits/Catalyst-Runtime.git] / t / live_component_controller_action_childof.t
CommitLineData
141459fa 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/lib";
8
9our $iters;
10
11BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
12
13use Test::More tests => 9*$iters;
14use Catalyst::Test 'TestApp';
15
16if ( $ENV{CAT_BENCHMARK} ) {
17 require Benchmark;
18 Benchmark::timethis( $iters, \&run_tests );
19}
20else {
21 for ( 1 .. $iters ) {
22 run_tests();
23 }
24}
25
26sub 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
a7edfd93 32 TestApp::Controller::Action::ChildOf->end
141459fa 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
a7edfd93 47 TestApp::Controller::Action::ChildOf->end
141459fa 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
a7edfd93 62 TestApp::Controller::Action::ChildOf->end
141459fa 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}