Add module version detecting to this test to handle WRE and non-WRE

installations of WebGUI.
This commit is contained in:
Colin Kuskie 2009-01-27 03:07:13 +00:00
parent f47cb2ffdd
commit 6b7886c856

View file

@ -19,40 +19,51 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session; my $session = WebGUI::Test->session;
use LWP::MediaTypes;
my $recentModule = $LWP::MediaTypes::VERSION > 5.800;
my @testSets = ( my @testSets = (
{ {
input => 'webgui.txt', input => 'webgui.txt',
output => 'text/plain', newput => 'text/plain',
oldput => 'text/plain',
comment => q|text|, comment => q|text|,
}, },
{ {
input => 'plainblack.gif', input => 'plainblack.gif',
output => 'image/gif', newput => 'image/gif',
oldput => 'image/gif',
comment => q|gif|, comment => q|gif|,
}, },
{ {
input => 'background.jpg', input => 'background.jpg',
output => 'image/jpeg', newput => 'image/jpeg',
oldput => 'image/jpeg',
comment => q|jpeg|, comment => q|jpeg|,
}, },
{ {
input => 'colorPicker.js', input => 'colorPicker.js',
output => 'application/octet-stream', newput => 'application/x-javascript',
oldput => 'application/octet-stream',
comment => q|javascript|, comment => q|javascript|,
}, },
{ {
input => 'favIcon.ico', input => 'favIcon.ico',
output => 'application/octet-stream', newput => 'image/vnd.microsoft.icon',
oldput => 'application/octet-stream',
comment => q|octet-stream for unknown type|, comment => q|octet-stream for unknown type|,
}, },
{ {
input => '', input => '',
output => 'application/octet-stream', newput => 'application/octet-stream',
oldput => 'application/octet-stream',
comment => q|Null path returns application/octet-stream|, comment => q|Null path returns application/octet-stream|,
}, },
{ {
input => undef, input => undef,
output => undef, newput => undef,
oldput => undef,
comment => q|Undef path returns undef|, comment => q|Undef path returns undef|,
}, },
); );
@ -75,7 +86,8 @@ foreach my $testSet (@testSets) {
? join '/', WebGUI::Test->root, 'www/extras', $testSet->{input} ? join '/', WebGUI::Test->root, 'www/extras', $testSet->{input}
: $testSet->{input}; : $testSet->{input};
my $output = WebGUI::Macro::FetchMimeType::process($session, $file); my $output = WebGUI::Macro::FetchMimeType::process($session, $file);
is($output, $testSet->{output}, $testSet->{comment} ); my $expected = $recentModule ? $testSet->{newput} : $testSet->{oldput};
is($output, $expected, $testSet->{comment} );
} }
} }