rename ENV to PSGI_ENV (*ENV is forced into main::)
[catagits/Web-Simple.git] / t / env.t
CommitLineData
298a02df 1use strict;
2use warnings FATAL => 'all';
3
4use Test::More (
5 eval { require HTTP::Request::AsCGI }
6 ? 'no_plan'
7 : (skip_all => 'No HTTP::Request::AsCGI')
8);
9
10{
11 use Web::Simple 'EnvTest';
12 package EnvTest;
13 dispatch {
14 sub (GET) {
c7b1c57f 15 my $env = @_[PSGI_ENV];
298a02df 16 [ 200,
17 [ "Content-type" => "text/plain" ],
18 [ 'foo' ]
19 ]
20 },
21 }
22}
23
24use HTTP::Request::Common qw(GET POST);
25
26my $app = EnvTest->new;
27
28sub run_request {
29 my $request = shift;
30 my $c = HTTP::Request::AsCGI->new($request)->setup;
31 $app->run;
32 $c->restore;
33 return $c->response;
34}
35
c7b1c57f 36ok run_request(GET 'http://localhost/')->is_success;