handle scripts that override $SIG{__DIE__} and $SIG{__WARN__}
[catagits/Catalyst-Controller-WrapCGI.git] / t / cgibin.t
CommitLineData
21a20b7e 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin '$Bin';
7use lib "$Bin/lib";
8
06d193b4 9use Test::More tests => 9;
21a20b7e 10
11use Catalyst::Test 'TestCGIBin';
12use HTTP::Request::Common;
13
46a4350c 14# this should be ignored
15$ENV{MOD_PERL} = "mod_perl/2.0";
16
9cc2dd4c 17my $response = request POST '/my-bin/path/test.pl', [
21a20b7e 18 foo => 'bar',
19 bar => 'baz'
20];
21
22is($response->content, 'foo:bar bar:baz', 'POST to Perl CGI File');
23
06d193b4 24$response = request '/my-bin/path/test.pl?foo=bar&bar=baz';
25
26is($response->content, 'foo:bar bar:baz',
27 'Perl CGI File invoked with query params');
28
bdb35995 29$response = request POST '/my-bin/exit.pl', [
30 name => 'world',
31];
32
33is($response->content, 'hello world', 'POST to Perl CGI with exit()');
34
35$response = request POST '/my-bin/exit.pl', [
36 name => 'world',
37 exit => 17,
38];
39
40is($response->code, 500, 'POST to Perl CGI with nonzero exit()');
41
21a20b7e 42$response = request POST '/cgihandler/dongs', [
43 foo => 'bar',
44 bar => 'baz'
45];
46
47is($response->content, 'foo:bar bar:baz',
48 'POST to Perl CGI File through a forward');
49
50$response = request POST '/cgihandler/mtfnpy', [
51 foo => 'bar',
52 bar => 'baz'
53];
54
55is($response->content, 'foo:bar bar:baz',
56 'POST to Perl CGI File through a forward via cgi_action');
57
63096ad1 58$response = request '/my-bin/path/testdata.pl';
fbaba9dd 59is($response->content, "testing\n",
60 'scripts with __DATA__ sections work');
61
f410f043 62$response = request '/my-bin/pathinfo.pl/path/info';
63is($response->content, '/path/info',
64 'PATH_INFO works');
65
21a20b7e 66SKIP: {
67 skip "Can't run shell scripts on non-*nix", 1
68 if $^O eq 'MSWin32' || $^O eq 'VMS';
69
5709e6bd 70# for some reason the +x is not preserved in the dist
71 system "chmod +x $Bin/lib/TestCGIBin/root/cgi-bin/test.sh";
72
9cc2dd4c 73 is(get('/my-bin/test.sh'), "Hello!\n", 'Non-Perl CGI File');
21a20b7e 74}