Commit | Line | Data |
e0e47c71 |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/../../../lib"; |
8 | |
232fd394 |
9 | our $iters; |
10 | |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } |
12 | |
13 | use Test::More tests => 19*$iters; |
e0e47c71 |
14 | use Catalyst::Test 'TestApp'; |
232fd394 |
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 { |
e0e47c71 |
27 | # test root index |
28 | { |
29 | ok( my $response = request('http://localhost/'), 'root index' ); |
30 | is( $response->content, 'root index', 'root index ok' ); |
31 | |
32 | ok( $response = request('http://localhost'), 'root index no slash' ); |
33 | is( $response->content, 'root index', 'root index no slash ok' ); |
34 | } |
35 | |
a83a5398 |
36 | # test first-level controller index |
e0e47c71 |
37 | { |
bf60b994 |
38 | my @expected = qw[ |
39 | TestApp::Controller::Index->index |
40 | ]; |
41 | |
42 | my $expected = join( ", ", @expected ); |
43 | |
a065abcf |
44 | ok( my $response = request('http://localhost/index/'), 'first-level controller index' ); |
bf60b994 |
45 | is( $response->header('X-Catalyst-Executed'), |
46 | $expected, 'Executed actions' ); |
a065abcf |
47 | is( $response->content, 'Index index', 'first-level controller index ok' ); |
e0e47c71 |
48 | |
a065abcf |
49 | ok( $response = request('http://localhost/index'), 'first-level controller index no slash' ); |
bf60b994 |
50 | is( $response->header('X-Catalyst-Executed'), |
51 | $expected, 'Executed actions' ); |
a065abcf |
52 | is( $response->content, 'Index index', 'first-level controller index no slash ok' ); |
a83a5398 |
53 | } |
54 | |
55 | # test second-level controller index |
56 | { |
bf60b994 |
57 | my @expected = qw[ |
58 | TestApp::Controller::Action::Index->begin |
59 | TestApp::Controller::Action::Index->index |
60 | ]; |
61 | |
62 | my $expected = join( ", ", @expected ); |
63 | |
a83a5398 |
64 | ok( my $response = request('http://localhost/action/index/'), 'second-level controller index' ); |
bf60b994 |
65 | is( $response->header('X-Catalyst-Executed'), |
66 | $expected, 'Executed actions' ); |
506b5a80 |
67 | is( $response->content, 'Action-Index index', 'second-level controller index ok' ); |
a83a5398 |
68 | |
69 | ok( $response = request('http://localhost/action/index'), 'second-level controller index no slash' ); |
bf60b994 |
70 | is( $response->header('X-Catalyst-Executed'), |
71 | $expected, 'Executed actions' ); |
506b5a80 |
72 | is( $response->content, 'Action-Index index', 'second-level controller index no slash ok' ); |
e0e47c71 |
73 | } |
74 | |
75 | # test controller default when index is present |
76 | { |
bf60b994 |
77 | my @expected = qw[ |
78 | TestApp::Controller::Action::Index->begin |
79 | TestApp::Controller::Action::Index->default |
80 | ]; |
81 | |
82 | my $expected = join( ", ", @expected ); |
83 | |
e0e47c71 |
84 | ok( my $response = request('http://localhost/action/index/foo'), 'default with index' ); |
bf60b994 |
85 | is( $response->header('X-Catalyst-Executed'), |
86 | $expected, 'Executed actions' ); |
e0e47c71 |
87 | is( $response->content, "Error - TestApp::Controller::Action\n", 'default with index ok' ); |
88 | } |
89 | } |