prepared for release of 5.65
[catagits/Catalyst-Runtime.git] / t / live_component_controller_action_local.t
CommitLineData
50cc3183 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
a2e038a1 7use lib "$FindBin::Bin/lib";
50cc3183 8
9our $iters;
10
11BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
12
595f3872 13use Test::More tests => 30*$iters;
50cc3183 14use Catalyst::Test 'TestApp';
15
16if ( $ENV{CAT_BENCHMARK} ) {
17 require Benchmark;
18 Benchmark::timethis( $iters, \&run_tests );
19}
20else {
21 for ( 1 .. $iters ) {
22 run_tests();
23 }
24}
25
26sub run_tests {
27 {
28 ok( my $response = request('http://localhost/action/local/one'),
29 'Request' );
30 ok( $response->is_success, 'Response Successful 2xx' );
31 is( $response->content_type, 'text/plain', 'Response Content-Type' );
32 is( $response->header('X-Catalyst-Action'),
33 'action/local/one', 'Test Action' );
34 is(
35 $response->header('X-Test-Class'),
36 'TestApp::Controller::Action::Local',
37 'Test Class'
38 );
39 like(
40 $response->content,
41 qr/^bless\( .* 'Catalyst::Request' \)$/s,
42 'Content is a serialized Catalyst::Request'
43 );
44 }
45
46 {
47 ok( my $response = request('http://localhost/action/local/two'),
48 'Request' );
49 ok( $response->is_success, 'Response Successful 2xx' );
50 is( $response->content_type, 'text/plain', 'Response Content-Type' );
51 is( $response->header('X-Catalyst-Action'),
52 'action/local/two', 'Test Action' );
53 is(
54 $response->header('X-Test-Class'),
55 'TestApp::Controller::Action::Local',
56 'Test Class'
57 );
58 like(
59 $response->content,
60 qr/^bless\( .* 'Catalyst::Request' \)$/s,
61 'Content is a serialized Catalyst::Request'
62 );
63 }
64
65 {
66 ok( my $response = request('http://localhost/action/local/three'),
67 'Request' );
68 ok( $response->is_success, 'Response Successful 2xx' );
69 is( $response->content_type, 'text/plain', 'Response Content-Type' );
70 is( $response->header('X-Catalyst-Action'),
71 'action/local/three', 'Test Action' );
72 is(
73 $response->header('X-Test-Class'),
74 'TestApp::Controller::Action::Local',
75 'Test Class'
76 );
77 like(
78 $response->content,
79 qr/^bless\( .* 'Catalyst::Request' \)$/s,
80 'Content is a serialized Catalyst::Request'
81 );
82 }
83
84 {
85 ok(
86 my $response =
87 request('http://localhost/action/local/four/five/six'),
88 'Request'
89 );
90 ok( $response->is_success, 'Response Successful 2xx' );
91 is( $response->content_type, 'text/plain', 'Response Content-Type' );
92 is( $response->header('X-Catalyst-Action'),
93 'action/local/four/five/six', 'Test Action' );
94 is(
95 $response->header('X-Test-Class'),
96 'TestApp::Controller::Action::Local',
97 'Test Class'
98 );
99 like(
100 $response->content,
101 qr/^bless\( .* 'Catalyst::Request' \)$/s,
102 'Content is a serialized Catalyst::Request'
103 );
104 }
595f3872 105
106 {
107 ok(
108 my $response =
109 request('http://localhost/action/local/two/foo%2Fbar'),
110 'Request'
111 );
112 ok( $response->is_success, 'Response Successful 2xx' );
113 is( $response->content_type, 'text/plain', 'Response Content-Type' );
114 is( $response->header('X-Catalyst-Action'),
115 'action/local/two', 'Test Action' );
116 is(
117 $response->header('X-Test-Class'),
118 'TestApp::Controller::Action::Local',
119 'Test Class'
120 );
121 like(
122 $response->content,
855ed931 123 qr~arguments => \[\s*'foo/bar'\s*\]~,
595f3872 124 "Parameters don't split on %2F"
125 );
126 }
50cc3183 127}