diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-07-18 16:22:08 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-07-18 16:22:08 -0500 |
commit | b5d66ba6e274eed251da951bb943b9ff67765290 (patch) | |
tree | 8b468f4ec6279a2d218f44d69a530c2a2476f1fc /t/base.t | |
parent | bc67313aa7191255f4123ae8d89f890e2f0772bc (diff) | |
download | web-request-b5d66ba6e274eed251da951bb943b9ff67765290.tar.gz web-request-b5d66ba6e274eed251da951bb943b9ff67765290.zip |
import the Plack::Request test suite
Diffstat (limited to 't/base.t')
-rw-r--r-- | t/base.t | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/t/base.t b/t/base.t new file mode 100644 index 0000000..af1a4ed --- /dev/null +++ b/t/base.t @@ -0,0 +1,53 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Web::Request; + +my @tests = ( + { host => 'localhost', + base => 'http://localhost/' }, + { script_name => '/foo', + host => 'localhost', + base => 'http://localhost/foo' }, + { script_name => '/foo bar', + host => 'localhost', + base => 'http://localhost/foo%20bar' }, + { scheme => 'http', + host => 'localhost:91', + base => 'http://localhost:91/' }, + { scheme => 'http', + host => 'example.com', + base => 'http://example.com/' }, + { scheme => 'https', + host => 'example.com', + base => 'https://example.com/' }, + { scheme => 'http', + server_name => 'example.com', + server_port => 80, + base => 'http://example.com/' }, + { scheme => 'http', + server_name => 'example.com', + server_port => 8080, + base => 'http://example.com:8080/' }, + { host => 'foobar.com', + server_name => 'example.com', + server_port => 8080, + base => 'http://foobar.com/' }, +); + +for my $block (@tests) { + my $env = { + 'psgi.url_scheme' => $block->{scheme} || 'http', + HTTP_HOST => $block->{host} || undef, + SERVER_NAME => $block->{server_name} || undef, + SERVER_PORT => $block->{server_port} || undef, + SCRIPT_NAME => $block->{script_name} || '', + }; + + my $req = Web::Request->new_from_env($env); + is $req->base_uri, $block->{base}; +} + +done_testing; |