re-re-fix FileUrl test with recommended method for building Assets

This commit is contained in:
Colin Kuskie 2006-12-09 04:48:03 +00:00
parent 6343f648e1
commit 332933337a

View file

@ -84,14 +84,10 @@ my @testSets = (
);
my $numTests = 0;
my $numTests = scalar @testSets;
$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';
@ -110,10 +106,7 @@ my $homeAsset = WebGUI::Asset->getDefault($session);
foreach my $testSet (@testSets) {
my $output = WebGUI::Macro::FileUrl::process($session, $testSet->{url});
if ($testSet->{pass}) {
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});
is($output, $testSet->{fileUrl}, $testSet->{comment});
}
else {
is($output, $testSet->{output}, $testSet->{comment});
@ -141,10 +134,14 @@ sub setupTest {
$testSet->{fileUrl} = $storage->getUrl($filename);
my %properties = %{ $testSet };
$properties{storageId} = $storage->getId;
$properties{filename} = $filename;
my $asset = $homeAsset->addChild(\%properties, $properties{assetId});
##It is not recommended that you create the asset with the
##storageId and filename as properties.
$asset->update({
storageId => $storage->getId,
filename => $filename,
});
$testSet->{asset} = $asset;
++$testNum;
}