Rework all tests to call the Macro's process subroutine directly.
Add RootTitle.t test. Broke up the SettingMacros.t test into individual tests.
This commit is contained in:
parent
60e9523f7b
commit
6aab9a6eec
32 changed files with 433 additions and 623 deletions
|
|
@ -13,40 +13,33 @@ use strict;
|
|||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Macro::FetchMimeType;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Macro_Config;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my @added_macros = ();
|
||||
push @added_macros, WebGUI::Macro_Config::enable_macro($session, 'FetchMimeType', 'FetchMimeType');
|
||||
|
||||
my $macroText = '^FetchMimeType("%s");';
|
||||
my $output;
|
||||
|
||||
my @testSets = (
|
||||
{
|
||||
input => 'plainblack.gif',
|
||||
output => 'image/gif',
|
||||
comment => q|gif|,
|
||||
input => 'plainblack.gif',
|
||||
output => 'image/gif',
|
||||
comment => q|gif|,
|
||||
},
|
||||
{
|
||||
input => 'background.jpg',
|
||||
output => 'image/jpeg',
|
||||
comment => q|jpeg|,
|
||||
input => 'background.jpg',
|
||||
output => 'image/jpeg',
|
||||
comment => q|jpeg|,
|
||||
},
|
||||
{
|
||||
input => 'colorPicker.js',
|
||||
output => 'text/plain',
|
||||
comment => q|plain text|,
|
||||
input => 'colorPicker.js',
|
||||
output => 'text/plain',
|
||||
comment => q|plain text|,
|
||||
},
|
||||
{
|
||||
input => 'favIcon.ico',
|
||||
output => 'application/octet-stream',
|
||||
comment => q|octet-stream for unknown type|,
|
||||
input => 'favIcon.ico',
|
||||
output => 'application/octet-stream',
|
||||
comment => q|octet-stream for unknown type|,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -54,17 +47,9 @@ my $numTests = scalar @testSets;
|
|||
|
||||
plan tests => $numTests;
|
||||
|
||||
|
||||
foreach my $testSet (@testSets) {
|
||||
my $file = join '/', WebGUI::Test->root, 'www/extras', $testSet->{input};
|
||||
$output = sprintf $macroText, $file;
|
||||
WebGUI::Macro::process($session, \$output);
|
||||
my $output = WebGUI::Macro::FetchMimeType::process($session, $file);
|
||||
is($output, $testSet->{output}, $testSet->{comment} );
|
||||
}
|
||||
|
||||
END {
|
||||
foreach my $macro (@added_macros) {
|
||||
next unless $macro;
|
||||
$session->config->deleteFromHash("macros", $macro);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue