finish FileUrl test
This commit is contained in:
parent
0f8aca80db
commit
63db4ee2ed
1 changed files with 43 additions and 16 deletions
|
|
@ -22,6 +22,7 @@ use Data::Dumper;
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
my $i18n = WebGUI::International->new($session, 'Macro_FileUrl');
|
||||||
|
|
||||||
unless ($session->config->get('macros')->{'FileUrl'}) {
|
unless ($session->config->get('macros')->{'FileUrl'}) {
|
||||||
Macro_Config::insert_macro($session, 'FileUrl', 'FileUrl');
|
Macro_Config::insert_macro($session, 'FileUrl', 'FileUrl');
|
||||||
|
|
@ -37,30 +38,57 @@ my @testSets = (
|
||||||
title => 'Test File Asset',
|
title => 'Test File Asset',
|
||||||
url => 'fileurltest-file',
|
url => 'fileurltest-file',
|
||||||
description => 'Test File Asset for the FileUrl macro test',
|
description => 'Test File Asset for the FileUrl macro test',
|
||||||
|
pass => 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
className => 'Image Asset works with FileUrl',
|
comment => 'Image Asset works with FileUrl',
|
||||||
|
className => 'WebGUI::Asset::File::Image',
|
||||||
# '1234567890123456789012'
|
# '1234567890123456789012'
|
||||||
assetId => 'ImageAsset0110011abc-e',
|
assetId => 'ImageAsset0110011abc-e',
|
||||||
title => 'Test Image Asset',
|
title => 'Test Image Asset',
|
||||||
url => 'fileurltest-image',
|
url => 'fileurltest-image',
|
||||||
description => 'Test Image Asset for the FileUrl macro test',
|
description => 'Test Image Asset for the FileUrl macro test',
|
||||||
|
pass => 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
className => 'Article Asset does not work with FileUrl',
|
comment => 'ZipArchive Asset works with FileUrl',
|
||||||
|
className => 'WebGUI::Asset::File::ZipArchive',
|
||||||
# '1234567890123456789012'
|
# '1234567890123456789012'
|
||||||
assetId => 'ArticleAsset10011abc-e',
|
assetId => 'ZipArchive0110011ZYWXV',
|
||||||
|
title => 'Test ZipArchive Asset',
|
||||||
|
url => 'fileurltest-ziparchive',
|
||||||
|
description => 'Test ZipArchive Asset for the FileUrl macro test',
|
||||||
|
pass => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
comment => 'Snippet Asset does not store files',
|
||||||
|
className => 'WebGUI::Asset::Snippet',
|
||||||
|
# '1234567890123456789012'
|
||||||
|
assetId => 'SnippetAsset01011abc-e',
|
||||||
|
title => 'Test Snippet Asset',
|
||||||
|
url => 'fileurltest-snippet',
|
||||||
|
description => 'Test Snippet Asset for the FileUrl macro test',
|
||||||
|
snippet => 'Test Snippet Asset for the FileUrl macro test',
|
||||||
|
pass => 0,
|
||||||
|
output => $i18n->get('no storage'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
comment => 'Article Asset does not have a filename property',
|
||||||
|
className => 'WebGUI::Asset::Wobject::Article',
|
||||||
|
# '1234567890123456789012'
|
||||||
|
assetId => 'ArticleAsset01011abc-e',
|
||||||
title => 'Test Article Asset',
|
title => 'Test Article Asset',
|
||||||
url => 'fileurltest-Article',
|
url => 'fileurltest-article',
|
||||||
description => 'Test Article Asset for the FileUrl macro test',
|
description => 'Test Article Asset for the FileUrl macro test',
|
||||||
|
pass => 0,
|
||||||
|
output => $i18n->get('no filename'),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
plan tests => scalar(@testSets) + 3; ##3 TODO tests
|
plan tests => scalar(@testSets) + 1;
|
||||||
|
|
||||||
my $macroText = '^FileUrl("%s");';
|
my $macroText = '^FileUrl("%s");';
|
||||||
my $output = $macroText;
|
|
||||||
|
|
||||||
my $homeAsset = WebGUI::Asset->getDefault($session);
|
my $homeAsset = WebGUI::Asset->getDefault($session);
|
||||||
my $versionTag;
|
my $versionTag;
|
||||||
|
|
@ -68,20 +96,19 @@ my $versionTag;
|
||||||
($versionTag, @testSets) = setupTest($session, $homeAsset, @testSets);
|
($versionTag, @testSets) = setupTest($session, $homeAsset, @testSets);
|
||||||
|
|
||||||
foreach my $testSet (@testSets) {
|
foreach my $testSet (@testSets) {
|
||||||
$session->asset($testSet->{asset});
|
|
||||||
my $class = $testSet->{className};
|
|
||||||
my $output = sprintf $macroText, $testSet->{url};
|
my $output = sprintf $macroText, $testSet->{url};
|
||||||
WebGUI::Macro::process($session, \$output);
|
WebGUI::Macro::process($session, \$output);
|
||||||
my $comment = sprintf "Checking asset: %s", $class;
|
if ($testSet->{pass}) {
|
||||||
is($output, $testSet->{fileUrl}, $comment);
|
is($output, $testSet->{fileUrl}, $testSet->{comment});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
is($output, $testSet->{output}, $testSet->{comment});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TODO: {
|
my $output = sprintf $macroText, "non-existant-url";
|
||||||
local $TODO = 'Things to do later';
|
WebGUI::Macro::process($session, \$output);
|
||||||
ok(0, 'Add tests for Assets with no Storage ID and check error message');
|
is($output, $i18n->get('invalid url'), "Non-existant url returns error message");
|
||||||
ok(0, 'Add tests for bad URLs and check error message');
|
|
||||||
ok(0, 'Talk to JT about how to handle Assets with StorageIds but no filename properties');
|
|
||||||
}
|
|
||||||
|
|
||||||
sub setupTest {
|
sub setupTest {
|
||||||
my ($session, $homeAsset, @testSets) = @_;
|
my ($session, $homeAsset, @testSets) = @_;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue