webgui/t/Asset/File/GalleryFile/Photo/download.t
Doug Bell ab6f4defe3 - moved Gallery utility methods to WebGUI::Utility::Gallery
- Added tests for GalleryAlbum RSS
- More tests for comments
- Test International Macro sprintf as third+ arguments
- Add Gallery search limiting by user ID
- Remaining i18n for Gallery templates
- Fix: Search form now visible in Photo assets
Moved a lot of stuff from Photo to GalleryFile
2008-03-20 18:51:44 +00:00

97 lines
2.9 KiB
Perl

#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
# The goal of this test is to test the getDownloadFileUrl and www_download()
# methods
use FindBin;
use strict;
use lib "$FindBin::Bin/../../../../lib";
use Scalar::Util qw( blessed );
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use Test::Deep;
use WebGUI::Asset::File::GalleryFile::Photo;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my @versionTags = ();
push @versionTags, WebGUI::VersionTag->getWorking($session);
$versionTags[-1]->set({name=>"Photo Test, add Gallery, Album and 1 Photo"});
my $versionTag = WebGUI::VersionTag->getWorking($session);
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "100\n200\n300",
groupIdView => 7,
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
$versionTags[-1]->commit;
#----------------------------------------------------------------------------
# Tests
plan tests => 3;
#----------------------------------------------------------------------------
# getResolutions returns an array reference of available resolutions
$photo->setFile( WebGUI::Test->getTestCollateralPath( "lamp.jpg" ) );
cmp_deeply(
$photo->getResolutions,
bag( "100.jpg", "200.jpg", "300.jpg" ),
"getResolutions returns the correct array reference",
);
#----------------------------------------------------------------------------
# getDownloadFileUrl returns the URL to download the resolution
is(
$photo->getDownloadFileUrl("100"),
$photo->getStorageLocation->getUrl( "100.jpg" ),
"getDownloadFileUrl returns the URL to download the resolution",
);
ok(
!eval{ $photo->getDownloadFileUrl("400"); 1 },
"getDownloadFileUrl croaks if resolution doesn't exist",
);
#----------------------------------------------------------------------------
# Cleanup
END {
foreach my $versionTag (@versionTags) {
$versionTag->rollback;
}
}