Fixed the failing FileUrl test and clearly document where the FileUrl macro

will work and where it will not.

This test failed due to an API change in WebGUI.  Before 7.3, if you created
a Storage object and then created an Asset with that Storage Id, then WebGUI
would do that happily.  This is actually a bug, because you could create multiple
Assets with that one Storage Id, and when _any_ of the Assets was deleted or
rolled back it would delete the Storage location and leave the other Assets
with that Id pointing to an empty Storage object.

So the API change is actually a bug fix, albeit being a side-effect of the
auto-commit work for posts and wikis.
This commit is contained in:
Colin Kuskie 2006-12-08 17:40:09 +00:00
parent ba72915167
commit 6343f648e1
2 changed files with 13 additions and 4 deletions

View file

@ -16,9 +16,9 @@ our $I18N = {
message => q|
<p><b>&#94;FileUrl</b>();<br />
<b>&#94;FileUrl</b>(<i>Asset URL</i>);<br />
This macro is used to return a filesystem URL to a File or Image Asset identified by its Asset URL.</p>
This macro is used to return a filesystem URL to an Asset which stores a single file (File, Image, ZipArchive, etc.) identified by its Asset URL. The Macro will <i>not</i> work on Assets which store multiple files, such as the Post or Article Assets.</p>
|,
lastUpdated => 1153476000,
lastUpdated => 1165599338,
},
'invalid url' => {

View file

@ -84,10 +84,14 @@ my @testSets = (
);
my $numTests = scalar(@testSets);
my $numTests = 0;
$numTests += 1; #For the use_ok
$numTests += 1; #non-existant URL
foreach my $testSet (@testSets) {
$numTests += $testSet->{pass} ? 2 : 1;
}
plan tests => $numTests;
my $macro = 'WebGUI::Macro::FileUrl';
@ -106,7 +110,10 @@ my $homeAsset = WebGUI::Asset->getDefault($session);
foreach my $testSet (@testSets) {
my $output = WebGUI::Macro::FileUrl::process($session, $testSet->{url});
if ($testSet->{pass}) {
is($output, $testSet->{fileUrl}, $testSet->{comment});
my $storageId = $testSet->{asset}->get("storageId");
my $expectedUrl = WebGUI::Storage->get($session, $storageId)->getUrl($testSet->{filename});
ok($expectedUrl, $testSet->{comment}." returns non-null file");
is($output, $expectedUrl, $testSet->{comment});
}
else {
is($output, $testSet->{output}, $testSet->{comment});
@ -127,6 +134,7 @@ sub setupTest {
my $storage = WebGUI::Storage->create($session);
my $filename = join '.', 'fileName', $testNum;
$testSet->{filename} = $filename;
##Store the filename in the file, just for reference.
$storage->addFileFromScalar($filename,$filename);
@ -145,5 +153,6 @@ sub setupTest {
}
END { ##Clean-up after yourself, always
use Data::Dumper;
$versionTag->rollback;
}