1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
use Test::More tests=>14;
# Include the test hierarchy
use lib 't/lib';
BEGIN { use_ok('TestApp5'); };
BEGIN { use_ok('CGI'); };
# Prevent output to STDOUT
$ENV{CGI_APP_RETURN_ONLY} = 1;
###
my $test_name = "mode_param( path_info => 1 ) with PATH_INFO set.";
$ENV{PATH_INFO} = '/basic_test1';
my $app = TestApp5->new;
$app->mode_param( path_info => 1 );
my $out;
eval { $out = $app->run() };
is($@, '', 'avoided eval() death');
like($out,qr/Hello World/, $test_name);
###
$test_name = "mode_param( path_info => 1 ) without PATH_INFO set, but with rm.";
$ENV{PATH_INFO} = '' ;
my $q = CGI->new({ rm => 'basic_test1' });
$app = TestApp5->new( QUERY => $q );
$app->mode_param( path_info => 1 );
eval { $out = $app->run() };
is($@, '', 'avoided eval() death');
like($out,qr/Hello World/, $test_name);
####
$test_name = "mode_param( param => 'alt_rm' ) ";
$ENV{PATH_INFO} = '';
$q = CGI->new({ alt_rm => 'basic_test1' });
$app = TestApp5->new( QUERY => $q );
$app->mode_param( param => 'alt_rm' );
eval { $out = $app->run() };
is($@, '', 'avoided eval() death');
like($out,qr/Hello World/, $test_name);
###
$test_name = "mode_param( path_info => 2 ), expecting success ";
$ENV{PATH_INFO} = '/my_ses_id/basic_test1/foo';
$app = TestApp5->new( QUERY => $q );
$app->mode_param( path_info => 2, );
eval { $out = $app->run() };
is($@, '', 'avoided eval() death');
like($out,qr/Hello World/, $test_name);
####
$test_name = "mode_param( path_info => 2, param => 'alt_rm' ), with path_info undef ";
$ENV{PATH_INFO} = '' ;
$app = TestApp5->new( QUERY => $q );
$app->mode_param( path_info => 2, param => 'alt_rm' );
eval { $out = $app->run() };
is($@, '', 'avoided eval() death');
like($out,qr/Hello World/, $test_name);
####
$test_name = "mode_param( path_info => -2 ), expecting success ";
$ENV{PATH_INFO} = '/my_ses_id/basic_test1/foo';
$app = TestApp5->new( QUERY => $q );
$app->mode_param( path_info => -2, );
eval { $out = $app->run() };
is($@, '', 'avoided eval() death');
like($out,qr/Hello World/, $test_name);
####
|