test for Env macro. It grabs all keys from the env object and makes sure they can be retrieved via the macro. It also tests null, undef and non-existant keys
This commit is contained in:
parent
23cc777add
commit
d9b4b1df06
1 changed files with 47 additions and 0 deletions
47
t/Macro/Env.t
Normal file
47
t/Macro/Env.t
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# Please read the legal notices (docs/legal.txt) and the license
|
||||||
|
# (docs/license.txt) that came with this distribution before using
|
||||||
|
# this software.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# http://www.plainblack.com info@plainblack.com
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
use FindBin;
|
||||||
|
use strict;
|
||||||
|
use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
|
use WebGUI::Test;
|
||||||
|
use WebGUI::Macro::Env;
|
||||||
|
use WebGUI::Session;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
##The test will scan the ENV hash and make sure that any key found in it
|
||||||
|
##can be retrieved via the macro. There are also tests for null, undef,
|
||||||
|
##and non-existant keys.
|
||||||
|
|
||||||
|
my %env = %{ $session->env->{_env} };
|
||||||
|
my @keys = keys %env;
|
||||||
|
|
||||||
|
plan tests => 3 + scalar keys %env;
|
||||||
|
|
||||||
|
my $output;
|
||||||
|
|
||||||
|
$output = WebGUI::Macro::Env::process($session, '');
|
||||||
|
is($output, undef, 'null key');
|
||||||
|
|
||||||
|
$output = WebGUI::Macro::Env::process($session, undef);
|
||||||
|
is($output, undef, 'undef key');
|
||||||
|
|
||||||
|
$output = WebGUI::Macro::Env::process($session, 'KEY DOES NOT EXIST');
|
||||||
|
is($output, undef, 'non existent key');
|
||||||
|
|
||||||
|
foreach my $key (keys %env) {
|
||||||
|
my $output = WebGUI::Macro::Env::process($session, $key);
|
||||||
|
is($output, $env{$key}, 'Fetching: '.$key);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue