Moved some PAR stuff
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / detach.t
CommitLineData
fbcc39ad 1#!perl\r
2\r
3use strict;\r
4use warnings;\r
5\r
6use FindBin;\r
7use lib "$FindBin::Bin/../../../lib";\r
8\r
232fd394 9our $iters;\r
10\r
11BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }\r
12\r
13use Test::More tests => 18*$iters;\r
fbcc39ad 14use Catalyst::Test 'TestApp';\r
15\r
232fd394 16if ( $ENV{CAT_BENCHMARK} ) {\r
17 require Benchmark;\r
5a6c7ff6 18 Benchmark::timethis( $iters, \&run_tests );\r
232fd394 19}\r
20else {\r
21 for ( 1 .. $iters ) {\r
22 run_tests();\r
23 }\r
24}\r
25\r
26sub 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
01ba879f 33 TestApp->end\r
d8c66af5 34 ];\r
fbcc39ad 35\r
d8c66af5 36 my $expected = join( ", ", @expected );\r
fbcc39ad 37\r
d8c66af5 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
fbcc39ad 53\r
d8c66af5 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
01ba879f 60 TestApp->end\r
d8c66af5 61 ];\r
fbcc39ad 62\r
d8c66af5 63 my $expected = join( ", ", @expected );\r
fbcc39ad 64\r
d8c66af5 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
fbcc39ad 90\r
d8c66af5 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
fbcc39ad 100}\r