From 4768a8687e825ef9f49398f14d9edffdc4f4795f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 13 Apr 2009 17:56:44 +0000 Subject: [PATCH] Add storage locations to package data for a Story. With tests. --- lib/WebGUI/Asset/Story.pm | 10 +++++++--- t/Asset/Story.t | 22 +++++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/Asset/Story.pm b/lib/WebGUI/Asset/Story.pm index d58a1a303..08bf4df55 100644 --- a/lib/WebGUI/Asset/Story.pm +++ b/lib/WebGUI/Asset/Story.pm @@ -204,14 +204,18 @@ sub duplicatePhotoData { =head2 exportAssetData ( ) See WebGUI::AssetPackage::exportAssetData() for details. -Add the storage location to the export data. +Adds all storage locations to the package data. =cut sub exportAssetData { my $self = shift; - my $data = $self->next::method; - return $data; + my $exportData = $self->next::method; + PHOTO: foreach my $photo (@{ $self->getPhotoData }) { + next PHOTO unless $photo->{storageId}; + push @{ $exportData->{storage} }, $photo->{storageId}; + } + return $exportData; } #------------------------------------------------------------------- diff --git a/t/Asset/Story.t b/t/Asset/Story.t index 016a83b7d..e72240bfb 100644 --- a/t/Asset/Story.t +++ b/t/Asset/Story.t @@ -20,7 +20,7 @@ use Test::More; # increment this value for each test you create use Test::Deep; use Data::Dumper; -my $tests = 40; +my $tests = 42; plan tests => 1 + $tests ; @@ -54,8 +54,6 @@ $archiveTag->commit; my $storage1 = WebGUI::Storage->create($session); my $storage2 = WebGUI::Storage->create($session); WebGUI::Test->storagesToDelete($storage1, $storage2); -diag $storage1->getId; -diag $session->id->toHex($storage1->getId); SKIP: { @@ -364,6 +362,24 @@ isnt($newPhotoData->[1]->{storageId}, $photoData->[1]->{storageId}, '... and sto WebGUI::Test->storagesToDelete( map { $_->{storageId} } @{ $newPhotoData } ); +############################################################ +# +# exportAssetData +# +############################################################ + +my $exportData = $story->exportAssetData; +isa_ok($exportData, 'HASH', 'exportAssetData'); + +cmp_bag( + $exportData->{storage}, + [ + $storage1->getId, + $storage2->getId, + ], + '...asset package data has the storage locations in it' +); + } END {