added Test::Pod support
[catagits/Catalyst-Runtime.git] / t / 17uri.t
CommitLineData
c1056332 1package TestApp;
2
e05c5e3c 3use Catalyst qw[-Engine=Test];
c1056332 4
5TestApp->action( '!default' => \&default );
6TestApp->action( 'index/a/b' => \&default );
7
8sub 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
17package main;
18
45374ac6 19use Test::More tests => 6;
c1056332 20use 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}