stop using Moo as a test package
[catagits/Catalyst-Runtime.git] / t / aggregate / live_component_controller_args.t
CommitLineData
855ed931 1use strict;
2use warnings;
3
4use FindBin;
42da66a9 5use lib "$FindBin::Bin/../lib";
855ed931 6
7use URI::Escape;
8
9our @paths;
10our $iters;
11
12cd259d 12BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1;
855ed931 13
c7ded7aa 14 # add special paths to test here
15 @paths = (
16 # all reserved in uri's
17 qw~ : / ? [ ] @ ! $ & ' ( ) * + ; = ~, ',' , '#',
855ed931 18
c7ded7aa 19 # unreserved
20 'a'..'z','A'..'Z',0..9,qw( - . _ ~ ),
21 " ",
855ed931 22
c7ded7aa 23 # just to test %2F/%
24 [ qw~ / / ~ ],
855ed931 25
c7ded7aa 26 # testing %25/%25
27 [ qw~ % % ~ ],
28 );
855ed931 29}
30
642026ea 31use Test::More tests => 6*@paths * $iters;
855ed931 32use Catalyst::Test 'TestApp';
33
34if ( $ENV{CAT_BENCHMARK} ) {
35 require Benchmark;
36 Benchmark::timethis( $iters, \&run_tests );
37
38 # new dispatcher:
39 # 11 wallclock secs (10.14 usr + 0.20 sys = 10.34 CPU) @ 15.18/s (n=157)
40 # old dispatcher (r1486):
41 # 11 wallclock secs (10.34 usr + 0.20 sys = 10.54 CPU) @ 13.76/s (n=145)
42}
43else {
44 for ( 1 .. $iters ) {
45 run_tests();
46 }
47}
48
49sub run_tests {
50 run_test_for($_) for @paths;
51}
52
53sub run_test_for {
54 my $test = shift;
55
56 my $path;
57 if (ref $test) {
58 $path = join "/", map uri_escape($_), @$test;
59 $test = join '', @$test;
60 } else {
61 $path = uri_escape($test);
62 }
12cd259d 63
64 SKIP:
65 {
e7ca2e0e 66 # Skip %2F, ., [, (, and ) tests on real webservers
67 # Both Apache and lighttpd don't seem to like these
68 if ( $ENV{CATALYST_SERVER} && $path =~ /(?:%2F|\.|%5B|\(|\))/ ) {
12cd259d 69 skip "Skipping $path tests on remote server", 6;
70 }
855ed931 71
12cd259d 72 my $response;
855ed931 73
081ea922 74 ok( $response = request("http://localhost/args/args/$path"), "Requested /args/args/$path");
855ed931 75
12cd259d 76 is( $response->content, $test, "$test as args" );
855ed931 77
12cd259d 78 undef $response;
855ed931 79
081ea922 80 ok( $response = request("http://localhost/args/params/$path"), "Requested /args/params/$path");
855ed931 81
081ea922 82 is( $response->content, $test, "response content $test as params" );
642026ea 83
12cd259d 84 undef $response;
642026ea 85
12cd259d 86 if( $test =~ m{/} ) {
87 $test =~ s{/}{}g;
88 $path = uri_escape( $test );
89 }
642026ea 90
12cd259d 91 ok( $response = request("http://localhost/chained/multi_cap/$path/baz"), "Requested capture for path $path");
642026ea 92
12cd259d 93 is( $response->content, join( ', ', split( //, $test ) ) ."; ", "$test as capture" );
94 }
855ed931 95}
96