Deprecated WebGUI::Storage::Image. WebGUI::Storage can now do everything

WebGUI::Storage::Image can do.
This commit is contained in:
JT Smith 2008-11-26 16:06:18 +00:00
parent 2b3e88fd63
commit ee84cc7611
34 changed files with 399 additions and 470 deletions

View file

@ -48,7 +48,7 @@ my $session = WebGUI::Test->session;
my $ad;
my ($richAd, $textAd, $imageAd, $nonAd, $setAd);
my $adSpace;
my $imageStorage = WebGUI::Storage::Image->create($session);
my $imageStorage = WebGUI::Storage->create($session);
$imageStorage->addFileFromScalar('foo.bmp', 'This is not really an image');
SKIP: {
@ -215,7 +215,7 @@ END {
if (defined $adSpace and ref $adSpace eq 'WebGUI::AdSpace') {
$adSpace->delete;
}
if (defined $imageStorage and ref $imageStorage eq 'WebGUI::Storage::Image') {
if (defined $imageStorage and ref $imageStorage eq 'WebGUI::Storage') {
$imageStorage->delete;
}
}

View file

@ -87,7 +87,7 @@ my $fileStorage = WebGUI::Storage->create($session);
$mocker->set_always('getValue', $fileStorage->getId);
my $fileFormStorage = $asset->getStorageFromPost();
isa_ok($fileFormStorage, 'WebGUI::Storage', 'Asset::File::getStorageFromPost');
isnt(ref $fileFormStorage, 'WebGUI::Storage::Image', 'getStorageFromPost does not return an image storage object');
isnt(ref $fileFormStorage, 'WebGUI::Storage', 'getStorageFromPost does not return an image storage object');
END {
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {

View file

@ -23,7 +23,7 @@ BEGIN {
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Image;
use WebGUI::Storage::Image;
use WebGUI::Storage;
use WebGUI::Asset::File::Image;
use WebGUI::Form::File;
@ -37,7 +37,7 @@ my $square = WebGUI::Image->new($session, 100, 100);
$square->setBackgroundColor('#0000FF');
##Create a storage location
my $storage = WebGUI::Storage::Image->create($session);
my $storage = WebGUI::Storage->create($session);
##Save the image to the location
$square->saveToStorageLocation($storage, 'square.png');

View file

@ -24,7 +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;
use WebGUI::Storage;
#----------------------------------------------------------------------------
# Init
@ -47,7 +47,7 @@ my $product = $node->addChild({
is($product->getThumbnailUrl(), '', 'Product with no image1 property returns the empty string');
my $image = WebGUI::Storage::Image->create($session);
my $image = WebGUI::Storage->create($session);
$image->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'));
my $imagedProduct = $node->addChild({
@ -60,7 +60,7 @@ my $imagedProduct = $node->addChild({
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);
my $otherImage = WebGUI::Storage->create($session);
$otherImage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('gooey.jpg'));
ok($imagedProduct->getThumbnailUrl($otherImage), 'getThumbnailUrl with an explicit storageId returns something');

View file

@ -69,7 +69,7 @@ my $filename = "page_title.jpg";
my $pathedFile = WebGUI::Test->getTestCollateralPath($filename);
# Use some test collateral to create a storage location and assign it to our article
my $storage = WebGUI::Storage::Image->create($session);
my $storage = WebGUI::Storage->create($session);
my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
my $filenameOK = is ($storedFilename, $filename, 'storage created correctly');
@ -86,7 +86,7 @@ my $duplicateArticle = $article->duplicate();
isa_ok($duplicateArticle, 'WebGUI::Asset::Wobject::Article');
my $duplicateStorageId = $duplicateArticle->get("storageId");
my $duplicateStorage = WebGUI::Storage::Image->get($session,$duplicateStorageId);
my $duplicateStorage = WebGUI::Storage->get($session,$duplicateStorageId);
my $duplicateFilename = $duplicateStorage->getFiles->[0];
is ($duplicateFilename, $filename, "duplicate method copies collateral");
@ -96,7 +96,7 @@ is ($duplicateFilename, $filename, "duplicate method copies collateral");
$duplicateArticle->purge();
# The get method will create the directory if it doesnt exist... very strange.
$duplicateStorage = WebGUI::Storage::Image->get($session,$duplicateStorageId);
$duplicateStorage = WebGUI::Storage->get($session,$duplicateStorageId);
# so lets check for the file instead
$duplicateFilename = $duplicateStorage->getFiles->[0];

View file

@ -69,7 +69,7 @@ my $filename = "page_title.jpg";
my $pathedFile = WebGUI::Test->getTestCollateralPath($filename);
# Use some test collateral to create a storage location and assign it to our article
my $storage = WebGUI::Storage::Image->create($session);
my $storage = WebGUI::Storage->create($session);
my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
my $filenameOK = is ($storedFilename, $filename, 'storage created correctly');
@ -86,7 +86,7 @@ my $duplicateArticle = $article->duplicate();
isa_ok($duplicateArticle, 'WebGUI::Asset::Wobject::Article');
my $duplicateStorageId = $duplicateArticle->get("storageId");
my $duplicateStorage = WebGUI::Storage::Image->get($session,$duplicateStorageId);
my $duplicateStorage = WebGUI::Storage->get($session,$duplicateStorageId);
my $duplicateFilename = $duplicateStorage->getFiles->[0];
is ($duplicateFilename, $filename, "duplicate method copies collateral");
@ -96,7 +96,7 @@ is ($duplicateFilename, $filename, "duplicate method copies collateral");
$duplicateArticle->purge();
# The get method will create the directory if it doesnt exist... very strange.
$duplicateStorage = WebGUI::Storage::Image->get($session,$duplicateStorageId);
$duplicateStorage = WebGUI::Storage->get($session,$duplicateStorageId);
# so lets check for the file instead
$duplicateFilename = $duplicateStorage->getFiles->[0];

View file

@ -106,7 +106,7 @@ my $html = join "\n",
$header,
$formClass->new($session, {
name => 'StorageClass',
value => 'WebGUI::Storage::Image',
value => 'WebGUI::Storage',
})->toHtml,
$footer;
@ -114,7 +114,7 @@ my $html = join "\n",
@inputs = $forms[0]->inputs;
my $input = $inputs[0];
is($input->name, 'StorageClass', 'Checking input name');
is($input->value, 'WebGUI::Storage::Image', 'Checking default value');
is($input->value, 'WebGUI::Storage', 'Checking default value');
##Test Form Output parsing

View file

@ -16,7 +16,7 @@ use WebGUI::Test;
use WebGUI::Macro::Thumbnail;
use WebGUI::Session;
use WebGUI::Image;
use WebGUI::Storage::Image;
use WebGUI::Storage;
use Test::More; # increment this value for each test you create
use Test::Deep;
@ -46,7 +46,7 @@ my $square = WebGUI::Image->new($session, 100, 100);
$square->setBackgroundColor('#0000FF');
##Create a storage location
my $storage = WebGUI::Storage::Image->create($session);
my $storage = WebGUI::Storage->create($session);
##Save the image to the location
$square->saveToStorageLocation($storage, 'square.png');

View file

@ -16,7 +16,7 @@ our $todo;
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Image;
use WebGUI::Storage::Image;
use WebGUI::Storage;
use File::Spec;
use Test::More;
@ -84,7 +84,7 @@ $session->config->set('caseInsensitiveOS', 0);
#
####################################################
my $imageStore = WebGUI::Storage::Image->create($session);
my $imageStore = WebGUI::Storage->create($session);
my $expectedFiles = ['.', '..'];
cmp_bag($imageStore->getFiles(1), $expectedFiles, 'Starting with an empty storage object, no files in here except for . and ..');
$imageStore->addFileFromScalar('.dotfile', 'dot file');
@ -98,6 +98,7 @@ cmp_bag($imageStore->getFiles(), ['dot.file'], 'getFiles() returns normal fil
cmp_bag($imageStore->getFiles(1), $expectedFiles, 'getFiles(1) returns all files, including dot files');
$imageStore->addFileFromScalar('thumb-file.png', 'thumbnail file');
push @{ $expectedFiles}, 'thumb-file.png';
cmp_bag($imageStore->getFiles(), ['dot.file', ], 'getFiles() ignores thumb- file');
cmp_bag($imageStore->getFiles(1), $expectedFiles, '... even when the allFiles switch is passed');
@ -119,7 +120,7 @@ foreach my $extTest ( @{ $extensionTests } ) {
WebGUI::Test->interceptLogging();
my $thumbStore = WebGUI::Storage::Image->create($session);
my $thumbStore = WebGUI::Storage->create($session);
my $square = WebGUI::Image->new($session, 500, 500);
$square->setBackgroundColor('#FF0000');
$square->saveToStorageLocation($thumbStore, 'square.png');
@ -170,7 +171,7 @@ like($WebGUI::Test::logger_error, qr/^Couldn't read image to check the size of i
####################################################
my $imageCopy = $thumbStore->copy();
isa_ok($imageCopy, 'WebGUI::Storage::Image', 'copy returns an object');
isa_ok($imageCopy, 'WebGUI::Storage', 'copy returns an object');
cmp_bag(
$imageCopy->getFiles(),
['square.png'],
@ -217,7 +218,7 @@ is($thumbStore->getThumbnailUrl('square.png'), $thumbStore->getUrl('thumb-square
my $origMaxImageSize = $session->setting->get('maxImageSize');
my $sizeTest = WebGUI::Storage::Image->create($session);
my $sizeTest = WebGUI::Storage->create($session);
my $resizeTarget = 80;
$session->setting->set('maxImageSize', 200 );
@ -286,7 +287,7 @@ END {
foreach my $stor (
$imageStore, $thumbStore, $imageCopy, $sizeTest,
) {
ref $stor eq "WebGUI::Storage::Image" and $stor->delete;
ref $stor eq "WebGUI::Storage" and $stor->delete;
}
$session->setting->set('maxImageSize', $origMaxImageSize );
}