From d9b4b1df06fcd958db0b881ded4811b0253d1efd Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 27 Jul 2006 18:05:46 +0000 Subject: [PATCH] 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 --- t/Macro/Env.t | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 t/Macro/Env.t diff --git a/t/Macro/Env.t b/t/Macro/Env.t new file mode 100644 index 000000000..7464c89ec --- /dev/null +++ b/t/Macro/Env.t @@ -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); +}