X-Git-Url: http://git.shiar.net/perl/plp/.git/blobdiff_plain/e4fe75f6569d246cbd535dbc0852f72f4f9995c4..39e0e00b61b6910de1313ca83efa9f1c3b092650:/t/50-cgi.t diff --git a/t/50-cgi.t b/t/50-cgi.t index 6b0661a..0f3eeaf 100644 --- a/t/50-cgi.t +++ b/t/50-cgi.t @@ -5,6 +5,7 @@ use Cwd; use File::Basename qw( dirname ); use File::Spec; use Test::More; +use PLP::Functions qw( DecodeURI ); eval { require Test::LongString; @@ -23,7 +24,7 @@ eval { eval { require PerlIO::scalar }; plan skip_all => "PerlIO required (perl 5.8) to test PLP" if $@; -plan tests => 21; +plan tests => 24; require_ok('PLP::Backend::CGI') or BAIL_OUT(); @@ -36,7 +37,7 @@ my $ORGDIR = Cwd::getcwd(); open ORGOUT, '>&', *STDOUT; sub plp_is { - my ($test, $src, $expect, $env) = @_; + my ($test, $src, $expect, $env, $in) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; %ENV = ( @@ -54,6 +55,13 @@ sub plp_is { $env ? %{$env} : (), ); # Apache/2.2.4 CGI environment + if (defined $in) { + $ENV{CONTENT_LENGTH} = length $in; + $ENV{CONTENT_TYPE} = 'application/x-www-form-urlencoded'; + close STDIN; + open STDIN, '<', $in; + } + close STDOUT; open STDOUT, '>', \my $output; # STDOUT buffered to scalar select STDOUT; # output before start() (which selects PLPOUT) @@ -96,7 +104,9 @@ sub plp_ok { (my $name = $file) =~ s/[.][^.]+$//; $file = "$name.html"; my $infile = delete $replace{-input} // "$name.plp"; + my $addin = -e "$name.txt" && "$name.txt"; $name =~ s/^(\d*)-// and $name .= " ($1)"; + DecodeURI($name); my $out = eval { local $/ = undef; # slurp @@ -121,7 +131,7 @@ sub plp_ok { (.*?) }{ getwarning($2, $1, $infile) }msxge; - plp_is($name, $infile, $out, $env); + plp_is($name, $infile, $out, $env, $addin); } # 0*: permission checks using generated dummy files @@ -169,7 +179,6 @@ SKIP: { # 4*-7*: apache environment (default) plp_ok($_) for glob '[4-7]*.html'; -#TODO: %post #TODO: %fields #TODO: %cookie