test for FetchMimeType macro
This commit is contained in:
parent
b2a001389f
commit
3587af1479
1 changed files with 65 additions and 0 deletions
65
t/Macro/FetchMimeType.t
Normal file
65
t/Macro/FetchMimeType.t
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Macro_Config;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
unless ($session->config->get('macros')->{'FetchMimeType'}) {
|
||||
Macro_Config::insert_macro($session, 'FetchMimeType', 'FetchMimeType');
|
||||
}
|
||||
|
||||
|
||||
my $macroText = '^FetchMimeType("%s");';
|
||||
my $output;
|
||||
|
||||
my @testSets = (
|
||||
{
|
||||
input => 'plainblack.gif',
|
||||
output => 'image/gif',
|
||||
comment => q|gif|,
|
||||
},
|
||||
{
|
||||
input => 'background.jpg',
|
||||
output => 'image/jpeg',
|
||||
comment => q|jpeg|,
|
||||
},
|
||||
{
|
||||
input => 'colorPicker.js',
|
||||
output => 'text/plain',
|
||||
comment => q|plain text|,
|
||||
},
|
||||
{
|
||||
input => 'favIcon.ico',
|
||||
output => 'application/octet-stream',
|
||||
comment => q|octet-stream for unknown type|,
|
||||
},
|
||||
);
|
||||
|
||||
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);
|
||||
is($output, $testSet->{output}, $testSet->{comment} );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue