Commit | Line | Data |
c1056332 |
1 | package TestApp; |
2 | |
e05c5e3c |
3 | use Catalyst qw[-Engine=Test]; |
c1056332 |
4 | |
5 | TestApp->action( '!default' => \&default ); |
6 | TestApp->action( 'index/a/b' => \&default ); |
7 | |
8 | sub default { |
9 | my ( $self, $c ) = @_; |
10 | $c->res->headers->header( 'X-Arguments' => $c->req->arguments ); |
11 | $c->res->headers->header( 'X-Base' => $c->req->base ); |
12 | $c->res->headers->header( 'X-Path' => $c->req->path ); |
13 | $c->res->headers->content_type('text/plain'); |
14 | $c->res->output('ok'); |
15 | } |
16 | |
17 | package main; |
18 | |
45374ac6 |
19 | use Test::More tests => 6; |
c1056332 |
20 | use Catalyst::Test 'TestApp'; |
21 | |
22 | { |
23 | local %ENV; |
24 | |
c1056332 |
25 | my $response = request('/index?a=a&b=b'); |
26 | |
27 | ok( $response->headers->header('X-Base') eq 'http://localhost/' ); |
28 | ok( $response->headers->header('X-Arguments') eq 'index' ); |
29 | ok( $response->headers->header('X-Path') eq 'index' ); |
30 | } |
31 | |
32 | { |
33 | local %ENV; |
34 | |
35 | my $response = request('http://localhost:8080/index/a/b/c'); |
36 | |
37 | ok( $response->headers->header('X-Base') eq 'http://localhost:8080/' ); |
38 | ok( $response->headers->header('X-Arguments') eq 'c' ); |
39 | ok( $response->headers->header('X-Path') eq 'index/a/b/c' ); |
40 | } |