whitespace cleanup
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Engine / Request / URI.pm
CommitLineData
c7ded7aa 1package TestApp::Controller::Engine::Request::URI;
2
3use strict;
c057ae86 4use base 'Catalyst::Controller';
c7ded7aa 5
6sub default : Private {
7 my ( $self, $c ) = @_;
88e5a8b0 8
c7ded7aa 9 $c->forward('TestApp::View::Dump::Request');
10}
11
12sub change_path : Local {
13 my ( $self, $c ) = @_;
88e5a8b0 14
c7ded7aa 15 # change the path
16 $c->req->path( '/my/app/lives/here' );
88e5a8b0 17
c7ded7aa 18 $c->forward('TestApp::View::Dump::Request');
19}
20
21sub change_base : Local {
22 my ( $self, $c ) = @_;
88e5a8b0 23
c7ded7aa 24 # change the base and uri paths
25 $c->req->base->path( '/new/location' );
26 $c->req->uri->path( '/new/location/engine/request/uri/change_base' );
88e5a8b0 27
c7ded7aa 28 $c->forward('TestApp::View::Dump::Request');
29}
30
31sub uri_with : Local {
32 my ( $self, $c ) = @_;
33
34 # change the current uri
6ebb7818 35 my $uri = $c->req->uri_with( { b => 1, c => undef } );
c7ded7aa 36 my %query = $uri->query_form;
88e5a8b0 37
c7ded7aa 38 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
39 $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );
6ebb7818 40 $c->res->header( 'X-Catalyst-Param-c' => exists($query{ c }) ? $query{ c } : '--notexists--' );
41 $c->res->header( 'X-Catalyst-query' => $uri->query);
88e5a8b0 42
c7ded7aa 43 $c->forward('TestApp::View::Dump::Request');
44}
45
46sub uri_with_object : Local {
47 my ( $self, $c ) = @_;
48
49 my $uri = $c->req->uri_with( { a => $c->req->base } );
50 my %query = $uri->query_form;
88e5a8b0 51
c7ded7aa 52 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
88e5a8b0 53
c7ded7aa 54 $c->forward('TestApp::View::Dump::Request');
55}
56
57sub uri_with_utf8 : Local {
58 my ( $self, $c ) = @_;
59
60 # change the current uri
61 my $uri = $c->req->uri_with( { unicode => "\x{2620}" } );
88e5a8b0 62
c7ded7aa 63 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
88e5a8b0 64
c7ded7aa 65 $c->forward('TestApp::View::Dump::Request');
66}
67
68sub uri_with_undef : Local {
69 my ( $self, $c ) = @_;
d0f0fcf6 70
71 my $warnings = 0;
c7ded7aa 72 local $SIG{__WARN__} = sub { $warnings++ };
73
d0f0fcf6 74 # change the current uri
c7ded7aa 75 my $uri = $c->req->uri_with( { foo => undef } );
88e5a8b0 76
c7ded7aa 77 $c->res->header( 'X-Catalyst-warnings' => $warnings );
88e5a8b0 78
c7ded7aa 79 $c->forward('TestApp::View::Dump::Request');
80}
81
2f381252 82sub uri_with_undef_only : Local {
83 my ( $self, $c ) = @_;
84
85 my $uri = $c->req->uri_with( { a => undef } );
88e5a8b0 86
2f381252 87 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
88 $c->forward('TestApp::View::Dump::Request');
89}
90
91sub uri_with_undef_ignore : Local {
92 my ( $self, $c ) = @_;
93
94 my $uri = $c->req->uri_with( { a => 1, b => undef } );
88e5a8b0 95
2f381252 96 my %query = $uri->query_form;
97 $c->res->header( 'X-Catalyst-uri-with' => "$uri" );
98 $c->res->header( 'X-Catalyst-Param-a' => $query{ a } );
99 $c->res->header( 'X-Catalyst-Param-b' => $query{ b } );
100 $c->res->header( 'X-Catalyst-Param-c' => $query{ c } );
101 $c->forward('TestApp::View::Dump::Request');
102}
103
c7ded7aa 1041;