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