webgui/t/Asset/File/Image/Photo/exif.t
2007-12-21 00:26:28 +00:00

76 lines
2.4 KiB
Perl

#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2007 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
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../../../../lib";
## The goal of this test is to test the EXIF functionality of WebGUI's photo
# asset
use Scalar::Util qw( blessed );
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use Test::Deep;
use Image::ExifTool qw(:Public);
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Photo Test"});
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
},
undef, undef,
{ skipAutoCommitWorkflows => 1 },
);
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::Image::Photo",
},
undef, undef,
{ skipAutoCommitWorkflows => 1 },
);
$versionTag->commit;
my $exif = ImageInfo( WebGUI::Test->getTestCollateralPath("lamp.jpg") );
$photo->setFile( WebGUI::Test->getTestCollateralPath("lamp.jpg") );
#----------------------------------------------------------------------------
# Cleanup
END {
$versionTag->rollback();
}
#----------------------------------------------------------------------------
# Tests
plan tests => 2;
#----------------------------------------------------------------------------
# Test getTemplateVars exif data
my $var = $photo->getTemplateVars;
cmp_deeply(
[ keys %$var ], superbagof( map { 'exif_' . $_ } keys %$exif ),
'getTemplateVars gets a hash of all exif tags',
);
is_deeply(
[ sort keys %$exif ],
[ sort map { $_->{tag} } @{ $var->{exifLoop} } ],
"getTemplateVars gets a loop over the tags",
);