moved
[catagits/Catalyst-Controller-WrapCGI.git] / t / cgibin.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin '$Bin';
7 use lib "$Bin/lib";
8
9 use Test::More tests => 7;
10
11 use Catalyst::Test 'TestCGIBin';
12 use HTTP::Request::Common;
13
14 # this should be ignored
15 $ENV{MOD_PERL} = "mod_perl/2.0";
16
17 my $response = request POST '/my-bin/path/test.pl', [
18     foo => 'bar',
19     bar => 'baz'
20 ];
21
22 is($response->content, 'foo:bar bar:baz', 'POST to Perl CGI File');
23
24 $response = request POST '/my-bin/exit.pl', [
25     name => 'world',
26 ];
27
28 is($response->content, 'hello world', 'POST to Perl CGI with exit()');
29
30 $response = request POST '/my-bin/exit.pl', [
31     name => 'world',
32     exit => 17,
33 ];
34
35 is($response->code, 500, 'POST to Perl CGI with nonzero exit()');
36
37 $response = request POST '/cgihandler/dongs', [
38     foo => 'bar',
39     bar => 'baz'
40 ];
41
42 is($response->content, 'foo:bar bar:baz',
43     'POST to Perl CGI File through a forward');
44
45 $response = request POST '/cgihandler/mtfnpy', [
46     foo => 'bar',
47     bar => 'baz'
48 ];
49
50 is($response->content, 'foo:bar bar:baz',
51     'POST to Perl CGI File through a forward via cgi_action');
52
53 $response = request '/my-bin/path/testdata.pl';
54 is($response->content, "testing\n",
55     'scripts with __DATA__ sections work');
56
57 SKIP: {
58     skip "Can't run shell scripts on non-*nix", 1
59         if $^O eq 'MSWin32' || $^O eq 'VMS';
60
61     is(get('/my-bin/test.sh'), "Hello!\n", 'Non-Perl CGI File');
62 }