finish up basic Date macro test
This commit is contained in:
parent
9c07548c71
commit
76ef4da780
2 changed files with 159 additions and 0 deletions
60
t/Macro/At_username.t
Normal file
60
t/Macro/At_username.t
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# 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
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ---- BEGIN DO NOT EDIT ----
|
||||||
|
use strict;
|
||||||
|
use lib '../../lib';
|
||||||
|
use Getopt::Long;
|
||||||
|
use WebGUI::Macro;
|
||||||
|
use WebGUI::Session;
|
||||||
|
use Data::Dumper;
|
||||||
|
# ---- END DO NOT EDIT ----
|
||||||
|
|
||||||
|
my $session = initialize(); # this line is required
|
||||||
|
|
||||||
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
|
my $numTests = 2;
|
||||||
|
|
||||||
|
plan tests => $numTests;
|
||||||
|
|
||||||
|
diag("Planning on running $numTests tests\n");
|
||||||
|
|
||||||
|
my $macroText = "^@;";
|
||||||
|
my $output;
|
||||||
|
|
||||||
|
$output = $macroText;
|
||||||
|
WebGUI::Macro::process($session, \$output);
|
||||||
|
is($output, 'Visitor', 'username = Visitor');
|
||||||
|
|
||||||
|
$output = $macroText;
|
||||||
|
$session->user({userId => 3});
|
||||||
|
WebGUI::Macro::process($session, \$output);
|
||||||
|
is($output, 'Admin', 'username = Admin');
|
||||||
|
|
||||||
|
cleanup($session); # this line is required
|
||||||
|
|
||||||
|
# ---- DO NOT EDIT BELOW THIS LINE -----
|
||||||
|
|
||||||
|
sub initialize {
|
||||||
|
$|=1; # disable output buffering
|
||||||
|
my $configFile;
|
||||||
|
GetOptions(
|
||||||
|
'configFile=s'=>\$configFile
|
||||||
|
);
|
||||||
|
exit 1 unless ($configFile);
|
||||||
|
my $session = WebGUI::Session->open("../..",$configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub cleanup {
|
||||||
|
my $session = shift;
|
||||||
|
$session->close();
|
||||||
|
}
|
||||||
|
|
||||||
99
t/Macro/SettingMacros.t
Normal file
99
t/Macro/SettingMacros.t
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# 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
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ---- BEGIN DO NOT EDIT ----
|
||||||
|
use strict;
|
||||||
|
use lib '../../lib';
|
||||||
|
use Getopt::Long;
|
||||||
|
use WebGUI::Macro;
|
||||||
|
use WebGUI::Session;
|
||||||
|
use Data::Dumper;
|
||||||
|
# ---- END DO NOT EDIT ----
|
||||||
|
|
||||||
|
my $session = initialize(); # this line is required
|
||||||
|
|
||||||
|
#This test is to verify bugs with respect to Macros:
|
||||||
|
# - [ 1364838 ] ^GroupText Macro cannot execute other macros
|
||||||
|
#
|
||||||
|
# It also checks some macros which pull data out of the setting table.
|
||||||
|
|
||||||
|
my @settingMacros = (
|
||||||
|
{
|
||||||
|
settingKey => 'companyEmail',
|
||||||
|
macro => 'e_companyEmail'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
settingKey => 'companyName',
|
||||||
|
macro => 'c_companyName'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
settingKey => 'companyURL',
|
||||||
|
macro => 'u_companyUrl'
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
##Build a reverse hash of the macro settings in the session var so that
|
||||||
|
##we can lookup the aliases for each macro.
|
||||||
|
|
||||||
|
my %macroNames = reverse %{ $session->config->get('macros') };
|
||||||
|
|
||||||
|
my $settingMacros = 0;
|
||||||
|
|
||||||
|
foreach my $macro ( @settingMacros ) {
|
||||||
|
++$settingMacros;
|
||||||
|
if (exists $macroNames{ $macro->{macro} }) {
|
||||||
|
$macro->{shortcut} = $macroNames{ $macro->{macro} };
|
||||||
|
$macro->{skip} = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$macro->{skip} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
|
my $numTests = $settingMacros;
|
||||||
|
|
||||||
|
plan tests => $numTests;
|
||||||
|
|
||||||
|
diag("Planning on running $numTests tests\n");
|
||||||
|
|
||||||
|
foreach my $macro ( @settingMacros ) {
|
||||||
|
SKIP: {
|
||||||
|
skip("Unable to lookup macro: $macro->{macro}",1) if $macro->{skip};
|
||||||
|
my ($value) = $session->dbSlave->quickArray(
|
||||||
|
sprintf "select value from settings where name=%s",
|
||||||
|
$session->db->quote($macro->{settingKey})
|
||||||
|
);
|
||||||
|
my $macroVal = sprintf "^%s();", $macro->{shortcut};
|
||||||
|
WebGUI::Macro::process($session, \$macroVal);
|
||||||
|
is($value, $macroVal, sprintf "Testing %s", $macro->{macro});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup($session); # this line is required
|
||||||
|
|
||||||
|
# ---- DO NOT EDIT BELOW THIS LINE -----
|
||||||
|
|
||||||
|
sub initialize {
|
||||||
|
$|=1; # disable output buffering
|
||||||
|
my $configFile;
|
||||||
|
GetOptions(
|
||||||
|
'configFile=s'=>\$configFile
|
||||||
|
);
|
||||||
|
exit 1 unless ($configFile);
|
||||||
|
my $session = WebGUI::Session->open("../..",$configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub cleanup {
|
||||||
|
my $session = shift;
|
||||||
|
$session->close();
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue