Test uri_for with path = 0
[catagits/Catalyst-Runtime.git] / t / aggregate / live_component_controller_action_detach.t
1 use strict;
2 use warnings;
3
4 use FindBin;
5 use lib "$FindBin::Bin/../lib";
6
7 our $iters;
8
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
10
11 use Test::More tests => 18*$iters;
12 use Catalyst::Test 'TestApp';
13
14 if ( $ENV{CAT_BENCHMARK} ) {
15     require Benchmark;
16     Benchmark::timethis( $iters, \&run_tests );
17 }
18 else {
19     for ( 1 .. $iters ) {
20         run_tests();
21     }
22 }
23
24 sub 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
31           TestApp::Controller::Root->end
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
58           TestApp::Controller::Root->end
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 }