Added 10x loop around auto tests
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / auto.t
CommitLineData
e1bf532b 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/../../../lib";
8
b960cfb8 9use Test::More tests => 180;
e1bf532b 10use Catalyst::Test 'TestApp';
11
b960cfb8 12for ( 1 .. 10 ) {
13 # test auto + local method
14 {
15 my @expected = qw[
16 TestApp::Controller::Action::Auto->begin
17 TestApp::Controller::Action::Auto->auto
18 TestApp::Controller::Action::Auto->one
19 ];
20
21 my $expected = join( ", ", @expected );
22
23 ok( my $response = request('http://localhost/action/auto/one'), 'auto + local' );
24 is( $response->header('X-Catalyst-Executed'),
25 $expected, 'Executed actions' );
26 is( $response->content, 'one', 'Content OK' );
27 }
28
29 # test auto + default
30 {
31 my @expected = qw[
32 TestApp::Controller::Action::Auto->begin
33 TestApp::Controller::Action::Auto->auto
34 TestApp::Controller::Action::Auto->default
35 ];
36
37 my $expected = join( ", ", @expected );
38
39 ok( my $response = request('http://localhost/action/auto/anything'), 'auto + default' );
40 is( $response->header('X-Catalyst-Executed'),
41 $expected, 'Executed actions' );
42 is( $response->content, 'default', 'Content OK' );
43 }
44
45 # test auto + auto + local
46 {
47 my @expected = qw[
48 TestApp::Controller::Action::Auto::Deep->begin
49 TestApp::Controller::Action::Auto->auto
50 TestApp::Controller::Action::Auto::Deep->auto
51 TestApp::Controller::Action::Auto::Deep->one
52 ];
53
54 my $expected = join( ", ", @expected );
55
56 ok( my $response = request('http://localhost/action/auto/deep/one'), 'auto + auto + local' );
57 is( $response->header('X-Catalyst-Executed'),
58 $expected, 'Executed actions' );
59 is( $response->content, 'deep one', 'Content OK' );
60 }
61
62 # test auto + auto + default
63 {
64 my @expected = qw[
65 TestApp::Controller::Action::Auto::Deep->begin
66 TestApp::Controller::Action::Auto->auto
67 TestApp::Controller::Action::Auto::Deep->auto
68 TestApp::Controller::Action::Auto::Deep->default
69 ];
70
71 my $expected = join( ", ", @expected );
72
73 ok( my $response = request('http://localhost/action/auto/deep/anything'), 'auto + auto + default' );
74 is( $response->header('X-Catalyst-Executed'),
75 $expected, 'Executed actions' );
76 is( $response->content, 'deep default', 'Content OK' );
77 }
78
79 # test auto + failing auto + local + end
80 {
81 my @expected = qw[
82 TestApp::Controller::Action::Auto::Abort->begin
83 TestApp::Controller::Action::Auto->auto
84 TestApp::Controller::Action::Auto::Abort->auto
85 TestApp::Controller::Action::Auto::Abort->end
86 ];
87
88 my $expected = join( ", ", @expected );
89
90 ok( my $response = request('http://localhost/action/auto/abort/one'), 'auto + failing auto + local' );
91 is( $response->header('X-Catalyst-Executed'),
92 $expected, 'Executed actions' );
93 is( $response->content, 'abort end', 'Content OK' );
94 }
95
96 # test auto + failing auto + default + end
97 {
98 my @expected = qw[
99 TestApp::Controller::Action::Auto::Abort->begin
100 TestApp::Controller::Action::Auto->auto
101 TestApp::Controller::Action::Auto::Abort->auto
102 TestApp::Controller::Action::Auto::Abort->end
103 ];
104
105 my $expected = join( ", ", @expected );
106
107 ok( my $response = request('http://localhost/action/auto/abort/anything'), 'auto + failing auto + default' );
108 is( $response->header('X-Catalyst-Executed'),
109 $expected, 'Executed actions' );
110 is( $response->content, 'abort end', 'Content OK' );
111 }
e1bf532b 112}