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