-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30956b4
commit 8e6b18c
Showing
5 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!perl -wT | ||
|
||
use strict; | ||
use warnings; | ||
use Test::Most tests => 5; | ||
use Test::NoWarnings; | ||
|
||
eval 'use autodie qw(:all)'; # Test for open/close failures | ||
|
||
BEGIN { | ||
use_ok('CGI::Info'); | ||
} | ||
|
||
JSON: { | ||
my $json = '{ "first": "Nigel", "last": "Horne" }'; | ||
|
||
$ENV{'GATEWAY_INTERFACE'} = 'CGI/1.1'; | ||
$ENV{'REQUEST_METHOD'} = 'POST'; | ||
$ENV{'CONTENT_TYPE'} = 'application/json; charset=utf-8'; | ||
$ENV{'CONTENT_LENGTH'} = length($json); | ||
|
||
my $allowed = { 'first' => undef, 'last' => undef }; | ||
|
||
open (my $fin, '<', \$json); | ||
local *STDIN = $fin; | ||
|
||
my $i = new_ok('CGI::Info' => [ logger => MyLogger->new() ]); | ||
ok(defined($i->params(allow => $allowed))); | ||
ok($i->first() eq 'Nigel'); | ||
} | ||
|
||
package MyLogger; | ||
|
||
sub new { | ||
my ($proto, %args) = @_; | ||
|
||
my $class = ref($proto) || $proto; | ||
|
||
return bless { }, $class; | ||
} | ||
|
||
sub warn { | ||
my $self = shift; | ||
my $message = shift; | ||
|
||
::diag($message); | ||
} | ||
|
||
sub trace { | ||
my $self = shift; | ||
my $message = shift; | ||
|
||
if($ENV{'TEST_VERBOSE'}) { | ||
::diag($message); | ||
} | ||
} | ||
|
||
sub debug { | ||
my $self = shift; | ||
my $message = shift; | ||
|
||
if($ENV{'TEST_VERBOSE'}) { | ||
::diag($message); | ||
} | ||
} |