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