use Test::More tests => 319; use Carp; use strict; use vars qw(%field %in); use CGI::Simple; my ( $q, $sv, @av ); my $tmpfile = './cgi-tmpfile.tmp'; $ENV{'AUTH_TYPE'} = 'PGP MD5 DES rot13'; $ENV{'CONTENT_LENGTH'} = '42'; $ENV{'CONTENT_TYPE'} = 'application/x-www-form-urlencoded'; $ENV{'COOKIE'} = 'foo=a%20phrase; bar=yes%2C%20a%20phrase&I%20say;'; $ENV{'DOCUMENT_ROOT'} = '/vs/www/foo'; $ENV{'GATEWAY_INTERFACE'} = 'bleeding edge'; $ENV{'HTTPS'} = 'ON'; $ENV{'HTTPS_A'} = 'A'; $ENV{'HTTPS_B'} = 'B'; $ENV{'HTTP_ACCEPT'} = 'text/html;q=1, text/plain;q=0.8, image/jpg, image/gif;q=0.42, */*;q=0.001'; $ENV{'HTTP_COOKIE'} = ''; $ENV{'HTTP_FROM'} = 'spammer@nowhere.com'; $ENV{'HTTP_HOST'} = 'the.vatican.org'; $ENV{'HTTP_REFERER'} = 'xxx.sex.com'; $ENV{'HTTP_USER_AGENT'} = 'LWP'; $ENV{'PATH_INFO'} = '/somewhere/else'; $ENV{'PATH_TRANSLATED'} = '/usr/local/somewhere/else'; $ENV{'QUERY_STRING'} = 'name=JaPh%2C&color=red&color=green&color=blue'; $ENV{'REDIRECT_QUERY_STRING'} = ''; $ENV{'REMOTE_ADDR'} = '127.0.0.1'; $ENV{'REMOTE_HOST'} = 'localhost'; $ENV{'REMOTE_IDENT'} = 'None of your damn business'; $ENV{'REMOTE_USER'} = 'Just another Perl hacker,'; $ENV{'REQUEST_METHOD'} = 'GET'; $ENV{'SCRIPT_NAME'} = '/cgi-bin/foo.cgi'; $ENV{'SERVER_NAME'} = 'nowhere.com'; $ENV{'SERVER_PORT'} = '8080'; $ENV{'SERVER_PROTOCOL'} = 'HTTP/1.0'; $ENV{'SERVER_SOFTWARE'} = 'Apache - accept no substitutes'; $q = new CGI::Simple; sub undef_globals { undef $CGI::Simple::USE_CGI_PM_DEFAULTS; undef $CGI::Simple::DISABLE_UPLOADS; undef $CGI::Simple::POST_MAX; undef $CGI::Simple::NO_UNDEF_PARAMS; undef $CGI::Simple::USE_PARAM_SEMICOLONS; undef $CGI::Simple::HEADERS_ONCE; undef $CGI::Simple::NPH; undef $CGI::Simple::DEBUG; undef $CGI::Simple::NO_NULL; undef $CGI::Simple::FATAL; } undef_globals(); # _initialize_globals() $q->_initialize_globals(); is( $CGI::Simple::USE_CGI_PM_DEFAULTS, 0, '_initialize_globals(), 1' ); is( $CGI::Simple::DISABLE_UPLOADS, 1, '_initialize_globals(), 2' ); is( $CGI::Simple::POST_MAX, 102_400, '_initialize_globals(), 3' ); is( $CGI::Simple::NO_UNDEF_PARAMS, 0, '_initialize_globals(), 4' ); is( $CGI::Simple::USE_PARAM_SEMICOLONS, 0, '_initialize_globals(), 5' ); is( $CGI::Simple::HEADERS_ONCE, 0, '_initialize_globals(), 6' ); is( $CGI::Simple::NPH, 0, '_initialize_globals(), 7' ); is( $CGI::Simple::DEBUG, 0, '_initialize_globals(), 8' ); is( $CGI::Simple::NO_NULL, 1, '_initialize_globals(), 9' ); is( $CGI::Simple::FATAL, -1, '_initialize_globals(), 10' ); undef_globals(); # _use_cgi_pm_global_settings() $q->_use_cgi_pm_global_settings(); is( $CGI::Simple::DISABLE_UPLOADS, 0, '_use_cgi_pm_global_settings(), 1' ); is( $CGI::Simple::POST_MAX, -1, '_use_cgi_pm_global_settings(), 2' ); is( $CGI::Simple::NO_UNDEF_PARAMS, 0, '_use_cgi_pm_global_settings(), 3' ); is( $CGI::Simple::USE_PARAM_SEMICOLONS, 1, '_use_cgi_pm_global_settings(), 4' ); is( $CGI::Simple::HEADERS_ONCE, 0, '_use_cgi_pm_global_settings(), 5' ); is( $CGI::Simple::NPH, 0, '_use_cgi_pm_global_settings(), 6' ); is( $CGI::Simple::DEBUG, 1, '_use_cgi_pm_global_settings(), 7' ); is( $CGI::Simple::NO_NULL, 0, '_use_cgi_pm_global_settings(), 8' ); is( $CGI::Simple::FATAL, -1, '_use_cgi_pm_global_settings(), 9' ); # _store_globals() undef %{$q}; ok( !defined $q->{'.globals'}->{'DISABLE_UPLOADS'}, '_store_globals(), 1' ); ok( !defined $q->{'.globals'}->{'POST_MAX'}, '_store_globals(), 2' ); ok( !defined $q->{'.globals'}->{'NO_UNDEF_PARAMS'}, '_store_globals(), 3' ); ok( !defined $q->{'.globals'}->{'USE_PARAM_SEMICOLONS'}, '_store_globals(), 4' ); ok( !defined $q->{'.globals'}->{'HEADERS_ONCE'}, '_store_globals(), 5' ); ok( !defined $q->{'.globals'}->{'NPH'}, '_store_globals(), 6' ); ok( !defined $q->{'.globals'}->{'DEBUG'}, '_store_globals(), 7' ); ok( !defined $q->{'.globals'}->{'NO_NULL'}, '_store_globals(), 8' ); ok( !defined $q->{'.globals'}->{'FATAL'}, '_store_globals(), 9' ); ok( !defined $q->{'.globals'}->{'USE_CGI_PM_DEFAULTS'}, '_store_globals(), 10' ); $q->_store_globals(); ok( defined $q->{'.globals'}->{'DISABLE_UPLOADS'}, '_store_globals(), 11' ); ok( defined $q->{'.globals'}->{'POST_MAX'}, '_store_globals(), 12' ); ok( defined $q->{'.globals'}->{'NO_UNDEF_PARAMS'}, '_store_globals(), 13' ); ok( defined $q->{'.globals'}->{'USE_PARAM_SEMICOLONS'}, '_store_globals(), 14' ); ok( defined $q->{'.globals'}->{'HEADERS_ONCE'}, '_store_globals(), 15' ); ok( defined $q->{'.globals'}->{'NPH'}, '_store_globals(), 16' ); ok( defined $q->{'.globals'}->{'DEBUG'}, '_store_globals(), 17' ); ok( defined $q->{'.globals'}->{'NO_NULL'}, '_store_globals(), 18' ); ok( defined $q->{'.globals'}->{'FATAL'}, '_store_globals(), 19' ); ok( defined $q->{'.globals'}->{'USE_CGI_PM_DEFAULTS'}, '_store_globals(), 20' ); # import() - used to set paragmas my @args = qw( -default -no_upload -unique_header -nph -no_debug -newstyle_url -no_undef_param ); undef_globals(); $q->import( @args ); is( $CGI::Simple::USE_CGI_PM_DEFAULTS, 1, 'import(), 1' ); is( $CGI::Simple::DISABLE_UPLOADS, 1, 'import(), 2' ); is( $CGI::Simple::NO_UNDEF_PARAMS, 1, 'import(), 3' ); is( $CGI::Simple::USE_PARAM_SEMICOLONS, 1, 'import(), 4' ); is( $CGI::Simple::HEADERS_ONCE, 1, 'import(), 5' ); is( $CGI::Simple::NPH, 1, 'import(), 6' ); is( $CGI::Simple::DEBUG, 0, 'import(), 7' ); undef_globals(); $q->import( qw ( -upload -oldstyle_url -debug ) ); is( $CGI::Simple::DISABLE_UPLOADS, 0, 'import(), 8' ); is( $CGI::Simple::USE_PARAM_SEMICOLONS, 0, 'import(), 9' ); is( $CGI::Simple::DEBUG, 2, 'import(), 10' ); undef_globals(); # _reset_globals() $q->_reset_globals(); is( $CGI::Simple::DISABLE_UPLOADS, 0, '_reset_globals(), 1' ); is( $CGI::Simple::POST_MAX, -1, '_reset_globals(), 2' ); is( $CGI::Simple::NO_UNDEF_PARAMS, 0, '_reset_globals(), 3' ); is( $CGI::Simple::USE_PARAM_SEMICOLONS, 1, '_reset_globals(), 4' ); is( $CGI::Simple::HEADERS_ONCE, 0, '_reset_globals(), 5' ); is( $CGI::Simple::NPH, 0, '_reset_globals(), 6' ); is( $CGI::Simple::DEBUG, 1, '_reset_globals(), 7' ); is( $CGI::Simple::NO_NULL, 0, '_reset_globals(), 8' ); is( $CGI::Simple::FATAL, -1, '_reset_globals(), 9' ); undef_globals(); $q = new CGI::Simple; # url_decode() - scalar context, void argument $sv = $q->url_decode(); is( $sv, undef, 'url_decode(), 1' ); # url_decode() - scalar context, valid argument my ( $string, $enc_string ); for ( 32 .. 255 ) { $string .= chr; $enc_string .= uc sprintf "%%%02x", ord chr; } is( $q->url_decode( $enc_string ), $string, 'url_decode(\$enc_string), 1' ); # url_encode() - scalar context, void argument $sv = $q->url_encode(); is( $sv, undef, 'url_encode(), 1' ); # url_encode() - scalar context, valid argument $sv = $q->url_encode( $string ); $sv =~ tr/+/ /; $sv =~ s/%([a-fA-F0-9]{2})/ pack "C", hex $1 /eg; is( $sv, $string, 'url_encode(\$string), 1' ); # url encoding - circular test is( $q->url_decode( $q->url_encode( $string ) ), $string, 'url encoding via circular test, 1' ); # new() plain constructor $q = CGI::Simple->new; like( $q, qr/CGI::Simple/, 'new() plain constructor, 1' ); # new('') empty constructor $q = new CGI::Simple( '' ); like( $q, qr/CGI::Simple/, 'new() empty constructor, 1' ); $q = new CGI::Simple( {} ); like( $q, qr/CGI::Simple/, 'new() empty constructor, 2' ); # new() hash constructor $q = new CGI::Simple( { 'foo' => '1', 'bar' => [ 2, 3, 4 ] } ); @av = $q->param; # fix OS bug with testing is( join( ' ', sort @av ), 'bar foo', 'new() hash constructor, 1' ); is( $q->param( 'foo' ), 1, 'new() hash constructor, 2' ); is( $q->param( 'bar' ), 2, 'new() hash constructor, 3' ); @av = $q->param( 'bar' ); is( join( '', @av ), 234, 'new() hash constructor, 4' ); $q = new CGI::Simple( 'foo=1&bar=2&bar=3&bar=4' ); open FH, ">$tmpfile", or carp "Can't create $tmpfile $!\n"; $q->save( \*FH ); close FH; # new() query string constructor $q = new CGI::Simple( 'foo=5&bar=6&bar=7&bar=8' ); @av = $q->param; is( join( ' ', @av ), 'foo bar', 'new() query string constructor, 1' ); is( $q->param( 'foo' ), 5, 'new() query string constructor, 2' ); is( $q->param( 'bar' ), 6, 'new() query string constructor, 3' ); @av = $q->param( 'bar' ); is( join( '', @av ), 678, 'new() query string constructor, 4' ); open FH, ">>$tmpfile", or carp "Can't append $tmpfile $!\n"; $q->save_parameters( \*FH ); close FH; # new() CGI::Simple object constructor my $q_old = new CGI::Simple( 'foo=1&bar=2&bar=3&bar=4' ); my $q_new = new CGI::Simple( $q_old ); is( $q_old->query_string, 'foo=1&bar=2&bar=3&bar=4', 'new() CGI::Simple object constructor, 1' ); is( $q_new->query_string, 'foo=1&bar=2&bar=3&bar=4', 'new() CGI::Simple object constructor, 2' ); # new() \@ARGV constructor $ENV{'REQUEST_METHOD'} = ''; $CGI::Simple::DEBUG = 1; @ARGV = qw( foo=bar\=baz foo=bar\&baz ); $q = new CGI::Simple; is( join( ' ', $q->param( 'foo' ) ), 'bar=baz bar&baz', 'new() \@ARGV constructor, 1' ); $ENV{'REQUEST_METHOD'} = 'GET'; ################ The Core Methods ################ $q = new CGI::Simple; # param() - scalar and array context, void argument $sv = $q->param(); @av = $q->param(); is( $sv, '2', 'param() void argument, 1' ); is( join( ' ', @av ), 'name color', 'param() void argument, 2' ); # param() - scalar and array context, single argument (valid) $sv = $q->param( 'color' ); @av = $q->param( 'color' ); is( $sv, 'red', 'param(\'color\') single argument (valid), 1' ); is( join( ' ', @av ), 'red green blue', 'param(\'color\') single argument (valid), 2' ); # param() - scalar and array context, single argument (invalid) $sv = $q->param( 'invalid' ); @av = $q->param( 'invalid' ); is( $sv, undef, 'param(\'invalid\') single argument (invalid), 1' ); is( join( ' ', @av ), '', 'param(\'invalid\') single argument (invalid), 2' ); # param() - scalar and array context, -name=>'param' (valid) $sv = $q->param( -name => 'color' ); @av = $q->param( -name => 'color' ); is( $sv, 'red', 'param( -name=>\'color\' ) get values, 1' ); is( join( ' ', @av ), 'red green blue', 'param( -name=>\'color\' ) get values, 2' ); # param() - scalar and array context, -name=>'param' (invalid) $sv = $q->param( -name => 'invalid' ); @av = $q->param( -name => 'invalid' ); is( $sv, undef, 'param( -name=>\'invalid\' ) get values, 1' ); is( join( ' ', @av ), '', 'param( -name=>\'invalid\' ) get values, 2' ); $CGI::Simple::NO_UNDEF_PARAMS = 0; $q = new CGI::Simple( 'name=&color=' ); # param() - scalar and array context, void values void arg $sv = $q->param(); @av = $q->param(); is( $sv, '2', 'param() void values 1, 1' ); is( join( ' ', @av ), 'name color', 'param() void values 1, 2' ); # param() - scalar and array context, void values, valid arg $sv = $q->param( 'name' ); @av = $q->param( 'name' ); is( $sv, '', 'param(\'name\') void values 1, valid param, 1' ); is( join( ' ', @av ), '', 'param(\'name\') void values 1, valid param, 2' ); $q = new CGI::Simple( 'name&color' ); # param() - scalar and array context, void values void arg $sv = $q->param(); @av = $q->param(); is( $sv, '2', 'param() void values 2, 1' ); is( join( ' ', @av ), 'name color', 'param() void values 2, 2' ); # param() - scalar and array context, void values, valid arg $sv = $q->param( 'name' ); @av = $q->param( 'name' ); is( $sv, '', 'param(\'name\') void values 2 , valid param, 1' ); is( join( ' ', @av ), '', 'param(\'name\') void values 2 , valid param, 2' ); $CGI::Simple::NO_UNDEF_PARAMS = 1; $q = new CGI::Simple( 'name=&color=' ); # param() - scalar and array context, void values void arg $sv = $q->param(); @av = $q->param(); is( $sv, '0', 'param() void values 1, no undef, 1' ); is( join( ' ', @av ), '', 'param() void values 1, no undef, 2' ); # param() - scalar and array context, void values, valid arg $sv = $q->param( 'name' ); @av = $q->param( 'name' ); is( $sv, undef, 'param(\'name\') void values 1, valid param, no undef, 1' ); is( join( ' ', @av ), '', 'param(\'name\') void values 1, valid param, no undef, 2' ); $q = new CGI::Simple( 'name&color' ); # param() - scalar and array context, void values void arg $sv = $q->param(); @av = $q->param(); is( $sv, '0', 'param() void values 2, no undef, 1' ); is( join( ' ', @av ), '', 'param() void values 2, no undef, 2' ); # param() - scalar and array context, void values, valid arg $sv = $q->param( 'name' ); @av = $q->param( 'name' ); is( $sv, undef, 'param(\'name\') void values 2, valid param, no undef, 1' ); is( join( ' ', @av ), '', 'param(\'name\') void values 2, valid param, no undef, 2' ); $CGI::Simple::NO_UNDEF_PARAMS = 0; $q = new CGI::Simple; # param() - scalar and array context, set values $sv = $q->param( 'foo', 'some', 'new', 'values' ); @av = $q->param( 'foo', 'some', 'new', 'values' ); is( $sv, 'some', 'param( \'foo\', \'some\', \'new\', \'values\' ) set values, 1' ); is( join( ' ', @av ), 'some new values', 'param( \'foo\', \'some\', \'new\', \'values\' ) set values, 2' ); # param() - scalar and array context $sv = $q->param( -name => 'foo', -value => 'bar' ); @av = $q->param( -name => 'foo', -value => 'bar' ); is( $sv, 'bar', 'param( -name=>\'foo\', -value=>\'bar\' ) set values, 1' ); is( join( ' ', @av ), 'bar', 'param( -name=>\'foo\', -value=>\'bar\' ) set values, 2' ); # param() - scalar and array context $sv = $q->param( -name => 'foo', -value => [ 'bar', 'baz' ] ); @av = $q->param( -name => 'foo', -value => [ 'bar', 'baz' ] ); is( $sv, 'bar', 'param(-name=>\'foo\',-value=>[\'bar\',\'baz\']) set values, 1' ); is( join( ' ', @av ), 'bar baz', 'param(-name=>\'foo\',-value=>[\'bar\',\'baz\']) set values, 2' ); # add_param() - scalar and array context, void argument $sv = $q->add_param(); @av = $q->add_param(); is( $sv, undef, 'add_param(), 1' ); is( join( ' ', @av ), '', 'add_param(), 2' ); # add_param() - scalar and array context, existing param argument $q->add_param( 'foo', 'new' ); @av = $q->param( 'foo' ); is( join( ' ', @av ), 'bar baz new', 'add_param( \'foo\', \'new\' ), 1' ); $q->add_param( 'foo', [ 1, 2, 3, 4, 5 ] ); @av = $q->param( 'foo' ); is( join( ' ', @av ), 'bar baz new 1 2 3 4 5', 'add_param( \'foo\', \'new\' ), 2' ); # add_param() - existing param argument, overwrite $q->add_param( 'foo', 'bar', 'overwrite' ); @av = $q->param( 'foo' ); is( join( ' ', @av ), 'bar', 'add_param(\'foo\', \'bar\', \'overwrite\' ), 1' ); # add_param() - scalar and array context, existing param argument $q->add_param( 'new', 'new%2C' ); @av = $q->param( 'new' ); is( join( ' ', @av ), 'new%2C', 'add_param( \'new\', \'new\' ), 1' ); $q->add_param( 'new', [ 1, 2, 3, 4, 5 ] ); @av = $q->param( 'new' ); is( join( ' ', @av ), 'new%2C 1 2 3 4 5', 'add_param( \'new\', \'new\' ), 2' ); # param_fetch() - scalar context, void argument $sv = $q->param_fetch(); is( $sv, undef, 'param_fetch(), 1' ); # param_fetch() - scalar context, 'color' syntax $sv = $q->param_fetch( 'color' ); is( ref $sv, 'ARRAY', 'param_fetch( \'color\' ), 1' ); is( join( ' ', @$sv ), 'red green blue', 'param_fetch( \'color\' ), 2' ); # param_fetch() - scalar context, -name=>'color' syntax $sv = $q->param_fetch( -name => 'color' ); is( ref $sv, 'ARRAY', 'param_fetch( -name=>\'color\' ), 1' ); is( join( ' ', @$sv ), 'red green blue', 'param_fetch( -name=>\'color\' ), 2' ); # url_param() - scalar and array context, void argument $sv = $q->url_param(); @av = $q->url_param(); is( $sv, '2', 'url_param() void argument, 1' ); is( join( ' ', @av ), 'name color', 'url_param() void argument, 2' ); # url_param() - scalar and array context, single argument (valid) $sv = $q->url_param( 'color' ); @av = $q->url_param( 'color' ); is( $sv, 'red', 'url_param(\'color\') single argument (valid), 1' ); is( join( ' ', @av ), 'red green blue', 'url_param(\'color\') single argument (valid), 2' ); # url_param() - scalar and array context, single argument (invalid) $sv = $q->url_param( 'invalid' ); @av = $q->url_param( 'invalid' ); is( $sv, undef, 'url_param(\'invalid\') single argument (invalid), 1' ); is( join( ' ', @av ), '', 'url_param(\'invalid\') single argument (invalid), 2' ); # keywords() - scalar and array context, void argument $q = new CGI::Simple( 'here+are++++some%20keywords' ); $sv = $q->keywords; @av = $q->keywords; is( $sv, '4', 'keywords(), 1' ); is( join( ' ', @av ), 'here are some keywords', 'keywords(), 2' ); # keywords() - scalar and array context, array argument $sv = $q->keywords( 'foo', 'bar', 'baz' ); @av = $q->keywords( 'foo', 'bar', 'baz' ); is( $sv, '3', 'keywords( \'foo\', \'bar\', \'baz\' ), 1' ); is( join( ' ', @av ), 'foo bar baz', 'keywords( \'foo\', \'bar\', \'baz\' ), 2' ); # keywords() - scalar and array context, array ref argument $q = new CGI::Simple; $sv = $q->keywords( [ 'foo', 'man', 'chu' ] ); @av = $q->keywords( [ 'foo', 'man', 'chu' ] ); is( $sv, '3', 'keywords( [\'foo\', \'man\', \'chu\'] ), 1' ); is( join( ' ', @av ), 'foo man chu', 'keywords( [\'foo\', \'man\', \'chu\'] ), 2' ); $sv = $q->Vars(); is( $sv->{'color'}, "red\0green\0blue", 'Vars() - tied interface, 1' ); $sv->{'color'} = "foo\0bar\0baz"; is( join( ' ', $q->param( 'color' ) ), 'foo bar baz', 'Vars() - tied interface, 2' ); $q = new CGI::Simple; # Vars() - hash context, void argument my %hv = $q->Vars(); is( $hv{'name'}, 'JaPh,', 'Vars(), 1' ); # Vars() - hash context, "|" argument %hv = $q->Vars( ',' ); is( $hv{'color'}, 'red,green,blue', 'Vars(\',\'), 1' ); # append() - scalar and array context, void argument $sv = $q->append(); @av = $q->append(); is( $sv, undef, 'append(), 1' ); is( join( '', @av ), '', 'append(), 2' ); # append() - scalar and array context, set values, valid param $q->add_param( 'foo', 'bar', 'overwrite' ); $sv = $q->append( 'foo', 'some' ); @av = $q->append( 'foo', 'some-more' ); is( $sv, 'bar', 'append( \'foo\', \'some\' ) set values, 1' ); is( join( ' ', @av ), 'bar some some-more', 'append( \'foo\', \'some\' ) set values, 2' ); # append() - scalar and array context, set values, non-existant param $sv = $q->append( 'invalid', 'param1' ); @av = $q->append( 'invalid', 'param2' ); is( $sv, 'param1', 'append( \'invalid\', \'param\' ) set values, 1' ); is( join( ' ', @av ), 'param1 param2', 'append( \'invalid\', \'param\' ) set values, 2' ); is( join( ' ', $q->param( 'invalid' ) ), 'param1 param2', 'append( \'invalid\', \'param\' ) set values, 3' ); # append() - scalar and array context, set values $sv = $q->append( 'foo', 'some', 'new', 'values' ); @av = $q->append( 'foo', 'even', 'more', 'stuff' ); is( $sv, 'bar', 'append( \'foo\', \'some\', \'new\', \'values\' ) set values, 1' ); is( join( ' ', @av ), 'bar some some-more some new values even more stuff', 'append( \'foo\', \'some\', \'new\', \'values\' ) set values, 2' ); # append() - scalar and array context $sv = $q->append( -name => 'foo', -value => 'baz' ); @av = $q->append( -name => 'foo', -value => 'xyz' ); is( $sv, 'bar', 'append( -name=>\'foo\', -value=>\'bar\' ) set values, 1' ); is( join( ' ', @av ), 'bar some some-more some new values even more stuff baz xyz', 'append( -name=>\'foo\', -value=>\'bar\' ) set values, 2' ); # append() - scalar and array context $sv = $q->append( -name => 'foo', -value => [ 1, 2 ] ); @av = $q->append( -name => 'foo', -value => [ 3, 4 ] ); is( $sv, 'bar', 'append(-name=>\'foo\',-value=>[\'bar\',\'baz\']) set values, 1' ); is( join( ' ', @av ), 'bar some some-more some new values even more stuff baz xyz 1 2 3 4', 'append(-name=>\'foo\',-value=>[\'bar\',\'baz\']) set values, 2' ); # delete() - void/valid argument $q->delete(); is( join( ' ', $q->param ), 'name color foo invalid', 'delete(), 1' ); $q->delete( 'foo' ); is( join( ' ', $q->param ), 'name color invalid', 'delete(), 2' ); # Delete() - void/valid argument $q->Delete(); is( join( ' ', $q->param ), 'name color invalid', 'Delete(), 1' ); $q->Delete( 'invalid' ); is( join( ' ', $q->param ), 'name color', 'Delete(), 2' ); # delete_all() - scalar and array context, void/invalid/valid argument $q->delete_all(); is( join( '', $q->param ), '', 'delete_all(), 1' ); is( $q->globals, '11', 'delete_all(), 2' ); $ENV{'CONTENT_TYPE'} = 'NOT multipart/form-data'; $q = new CGI::Simple; # delete_all() - scalar and array context, void/invalid/valid argument is( join( ' ', $q->param ), 'name color', 'Delete_all(), 1' ); $q->Delete_all(); is( join( '', $q->param ), '', 'Delete_all(), 2' ); $ENV{'CONTENT_TYPE'} = 'application/x-www-form-urlencoded'; # upload() - invalid CONTENT_TYPE $sv = $q->upload( 'foo' ); is( $sv, undef, 'upload() - invalid CONTENT_TYPE, 1' ); is( $q->cgi_error(), 'Oops! File uploads only work if you specify ENCTYPE="multipart/form-data" in your