updated test to use C::E::Test
[catagits/Catalyst-Runtime.git] / t / 16uri.t
1 package TestApp;
2
3 use Catalyst qw[-Engine=Test];
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
19 use Test::More tests => 9;
20 use Catalyst::Test 'TestApp';
21
22 {
23     local %ENV;
24
25     $ENV{SCRIPT_NAME} = '/nph-catalyst.cgi';
26     $ENV{PATH_INFO}   = '/index';
27
28     my $response = request('/nph-catalyst.cgi/index');
29
30     ok( $response->headers->header('X-Base') eq 'http://localhost/nph-catalyst.cgi' );
31     ok( $response->headers->header('X-Arguments') eq 'index' );
32     ok( $response->headers->header('X-Path') eq 'index' );
33 }
34
35 {
36     local %ENV;
37
38     my $response = request('/index?a=a&b=b');
39
40     ok( $response->headers->header('X-Base') eq 'http://localhost/' );
41     ok( $response->headers->header('X-Arguments') eq 'index' );
42     ok( $response->headers->header('X-Path') eq 'index' );
43 }
44
45 {
46     local %ENV;
47
48     my $response = request('http://localhost:8080/index/a/b/c');
49
50     ok( $response->headers->header('X-Base') eq 'http://localhost:8080/' );
51     ok( $response->headers->header('X-Arguments') eq 'c' );
52     ok( $response->headers->header('X-Path') eq 'index/a/b/c' );
53 }