Commit | Line | Data |
fbcc39ad |
1 | #!perl\r |
2 | \r |
3 | use strict;\r |
4 | use warnings;\r |
5 | \r |
6 | use FindBin;\r |
7 | use lib "$FindBin::Bin/../../../lib";\r |
8 | \r |
232fd394 |
9 | our $iters;\r |
10 | \r |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }\r |
12 | \r |
13 | use Test::More tests => 18*$iters;\r |
fbcc39ad |
14 | use Catalyst::Test 'TestApp';\r |
15 | \r |
232fd394 |
16 | if ( $ENV{CAT_BENCHMARK} ) {\r |
17 | require Benchmark;\r |
5a6c7ff6 |
18 | Benchmark::timethis( $iters, \&run_tests );\r |
232fd394 |
19 | }\r |
20 | else {\r |
21 | for ( 1 .. $iters ) {\r |
22 | run_tests();\r |
23 | }\r |
24 | }\r |
25 | \r |
26 | sub run_tests {\r |
d8c66af5 |
27 | {\r |
28 | my @expected = qw[\r |
29 | TestApp::Controller::Action::Detach->begin\r |
30 | TestApp::Controller::Action::Detach->one\r |
31 | TestApp::Controller::Action::Detach->two\r |
32 | TestApp::View::Dump::Request->process\r |
33 | ];\r |
fbcc39ad |
34 | \r |
d8c66af5 |
35 | my $expected = join( ", ", @expected );\r |
fbcc39ad |
36 | \r |
d8c66af5 |
37 | # Test detach to chain of actions.\r |
38 | ok( my $response = request('http://localhost/action/detach/one'),\r |
39 | 'Request' );\r |
40 | ok( $response->is_success, 'Response Successful 2xx' );\r |
41 | is( $response->content_type, 'text/plain', 'Response Content-Type' );\r |
42 | is( $response->header('X-Catalyst-Action'),\r |
43 | 'action/detach/one', 'Test Action' );\r |
44 | is(\r |
45 | $response->header('X-Test-Class'),\r |
46 | 'TestApp::Controller::Action::Detach',\r |
47 | 'Test Class'\r |
48 | );\r |
49 | is( $response->header('X-Catalyst-Executed'),\r |
50 | $expected, 'Executed actions' );\r |
51 | }\r |
fbcc39ad |
52 | \r |
d8c66af5 |
53 | {\r |
54 | my @expected = qw[\r |
55 | TestApp::Controller::Action::Detach->begin\r |
56 | TestApp::Controller::Action::Detach->path\r |
57 | TestApp::Controller::Action::Detach->two\r |
58 | TestApp::View::Dump::Request->process\r |
59 | ];\r |
fbcc39ad |
60 | \r |
d8c66af5 |
61 | my $expected = join( ", ", @expected );\r |
fbcc39ad |
62 | \r |
d8c66af5 |
63 | # Test detach to chain of actions.\r |
64 | ok( my $response = request('http://localhost/action/detach/path'),\r |
65 | 'Request' );\r |
66 | ok( $response->is_success, 'Response Successful 2xx' );\r |
67 | is( $response->content_type, 'text/plain', 'Response Content-Type' );\r |
68 | is( $response->header('X-Catalyst-Action'),\r |
69 | 'action/detach/path', 'Test Action' );\r |
70 | is(\r |
71 | $response->header('X-Test-Class'),\r |
72 | 'TestApp::Controller::Action::Detach',\r |
73 | 'Test Class'\r |
74 | );\r |
75 | is( $response->header('X-Catalyst-Executed'),\r |
76 | $expected, 'Executed actions' );\r |
77 | }\r |
78 | \r |
79 | {\r |
80 | ok(\r |
81 | my $response =\r |
82 | request('http://localhost/action/detach/with_args/old'),\r |
83 | 'Request with args'\r |
84 | );\r |
85 | ok( $response->is_success, 'Response Successful 2xx' );\r |
86 | is( $response->content, 'new' );\r |
87 | }\r |
fbcc39ad |
88 | \r |
d8c66af5 |
89 | {\r |
90 | ok(\r |
91 | my $response = request(\r |
92 | 'http://localhost/action/detach/with_method_and_args/old'),\r |
93 | 'Request with args and method'\r |
94 | );\r |
95 | ok( $response->is_success, 'Response Successful 2xx' );\r |
96 | is( $response->content, 'new' );\r |
97 | }\r |
fbcc39ad |
98 | }\r |