Add tests to check how getThumbnailUrl is supposed to work in the Product.
Then fix the bugs I added to it yesterday.
This commit is contained in:
parent
2dac29bce5
commit
14724cbbef
5 changed files with 57 additions and 7 deletions
|
|
@ -24,6 +24,7 @@ use WebGUI::Test; # Must use this before any other WebGUI modules
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::Sku::Product;
|
||||
use WebGUI::Storage::Image;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
|
|
@ -33,7 +34,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 2; # Increment this number for each test you create
|
||||
plan tests => 7; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -41,10 +42,38 @@ my $node = WebGUI::Asset::Sku::Product->getProductImportNode($session);
|
|||
isa_ok($node, 'WebGUI::Asset::Wobject::Folder', 'getProductImportNode returns a Folder');
|
||||
is($node->getId, 'PBproductimportnode001', 'Product Import Node has the correct GUID');
|
||||
|
||||
my $product = $node->addChild({
|
||||
className => "WebGUI::Asset::Sku::Product",
|
||||
title => "Rock Hammer",
|
||||
});
|
||||
|
||||
is($product->getThumbnailUrl(), '', 'Product with no image1 property returns the empty string');
|
||||
|
||||
my $image = WebGUI::Storage::Image->create($session);
|
||||
$image->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'));
|
||||
|
||||
my $imagedProduct = $node->addChild({
|
||||
className => "WebGUI::Asset::Sku::Product",
|
||||
title => "Bible",
|
||||
image1 => $image->getId,
|
||||
});
|
||||
|
||||
ok($imagedProduct->getThumbnailUrl(), 'getThumbnailUrl is not empty');
|
||||
is($imagedProduct->getThumbnailUrl(), $image->getThumbnailUrl('lamp.jpg'), 'getThumbnailUrl returns the right path to the URL');
|
||||
|
||||
my $otherImage = WebGUI::Storage::Image->create($session);
|
||||
$otherImage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('gooey.jpg'));
|
||||
|
||||
ok($imagedProduct->getThumbnailUrl($otherImage), 'getThumbnailUrl with an explicit storageId returns something');
|
||||
is($imagedProduct->getThumbnailUrl($otherImage), $otherImage->getThumbnailUrl('gooey.jpg'), 'getThumbnailUrl with an explicit storageId returns the right path to the URL');
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
$product->purge;
|
||||
$imagedProduct->purge;
|
||||
$image->delete;
|
||||
$otherImage->delete;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ plan tests => 33; # Increment this number for each test you create
|
|||
# put your tests here
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
my $product = $root->addChild({
|
||||
className => "WebGUI::Asset::Sku::Product",
|
||||
title => "Rock Hammer",
|
||||
});
|
||||
className => "WebGUI::Asset::Sku::Product",
|
||||
title => "Rock Hammer",
|
||||
});
|
||||
isa_ok($product, "WebGUI::Asset::Sku::Product");
|
||||
ok(! exists $product->{_collateral}, 'object cache does not exist yet');
|
||||
|
||||
|
|
|
|||
BIN
t/supporting_collateral/gooey.jpg
Normal file
BIN
t/supporting_collateral/gooey.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Loading…
Add table
Add a link
Reference in a new issue