- 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
This commit is contained in:
parent
38256af5f6
commit
ab6f4defe3
25 changed files with 1386 additions and 905 deletions
|
|
@ -50,7 +50,7 @@ $versionTags[-1]->commit;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 29;
|
||||
plan tests => 32;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test with no comments
|
||||
|
|
@ -184,11 +184,70 @@ ok(
|
|||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsForCommentForm
|
||||
TODO: {
|
||||
local $TODO = "Test appendTemplateVarsForCommentForm";
|
||||
ok(0, "Test template variable generation");
|
||||
}
|
||||
# Test appendTemplateVarsForCommentForm for a new comment
|
||||
my $var = {};
|
||||
my $newVar = $photo->appendTemplateVarsCommentForm( $var );
|
||||
|
||||
is ( $var, $newVar, "appendTemplateVarsCommentForm returns the same hashref it's given" );
|
||||
cmp_deeply(
|
||||
$var,
|
||||
superhashof( {
|
||||
commentForm_start => all(
|
||||
re( qr/<input[^>]+name="func"[^>]+value="editCommentSave"[^>]+>/ ),
|
||||
re( qr/<input[^>]+name="commentId"[^>]+value="new"[^>]+>/ ),
|
||||
),
|
||||
commentForm_end => all(
|
||||
re( qr{</form>} ),
|
||||
),
|
||||
commentForm_bodyText => all(
|
||||
re( qr{<textarea[^>]+>} ),
|
||||
re( qr{TinyMCE}i ),
|
||||
),
|
||||
commentForm_submit => all(
|
||||
re( qr/<input[^>]+type="submit"[^>]+name="submit"[^>]+value="Save Comment"[^>]+>/ ),
|
||||
),
|
||||
} ),
|
||||
"appendTemplateVarsCommentForm returns the correct structure",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsForCommentForm for an existing comment
|
||||
$var = {};
|
||||
my $comment = {
|
||||
commentId => "new",
|
||||
bodyText => "New comment",
|
||||
creationDate => WebGUI::DateTime->new( $session, time )->toDatabase,
|
||||
userId => "3",
|
||||
};
|
||||
|
||||
my $commentId = $photo->setComment( $comment );
|
||||
|
||||
$newVar = $photo->appendTemplateVarsCommentForm( $var, $photo->getComment( $commentId ) );
|
||||
|
||||
is ( $var, $newVar, "appendTemplateVarsCommentForm returns the same hashref it's given" );
|
||||
cmp_deeply(
|
||||
$var,
|
||||
superhashof( {
|
||||
commentForm_start => all(
|
||||
re( qr/<input[^>]+name="func"[^>]+value="editCommentSave"[^>]+>/ ),
|
||||
re( qr/<input[^>]+name="commentId"[^>]+value="$commentId"[^>]+>/ ),
|
||||
re( qr/<input[^>]+name="creationDate"[^>]+value="$comment->{creationDate}"[^>]+>/ ),
|
||||
re( qr/<input[^>]+name="userId"[^>]+value="$comment->{userId}"[^>]+>/ ),
|
||||
),
|
||||
commentForm_end => all(
|
||||
re( qr{</form>} ),
|
||||
),
|
||||
commentForm_bodyText => all(
|
||||
re( qr{<textarea[^>]+>} ),
|
||||
re( qr{TinyMCE}i ),
|
||||
re( qr{$comment->{bodyText}} ),
|
||||
),
|
||||
commentForm_submit => all(
|
||||
re( qr/<input[^>]+type="submit"[^>]+name="submit"[^>]+value="Save Comment"[^>]+>/ ),
|
||||
),
|
||||
} ),
|
||||
"appendTemplateVarsCommentForm returns the correct structure",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_editCommentSave page sanity checks
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use Scalar::Util qw( blessed );
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Asset::File::GalleryFile::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -35,6 +36,7 @@ my $gallery
|
|||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
imageResolutions => "100\n200\n300",
|
||||
groupIdView => 7,
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
|
|
@ -46,7 +48,7 @@ my $album
|
|||
skipAutoCommitWorkflows => 1,
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::GalleryFile::Photo",
|
||||
},
|
||||
undef,
|
||||
|
|
@ -59,12 +61,30 @@ $versionTags[-1]->commit;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 1;
|
||||
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",
|
||||
);
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Write some tests for download testing';
|
||||
ok(0, 'No tests yet');
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use Scalar::Util qw( blessed );
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::GalleryFile::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -33,10 +32,20 @@ $versionTags[-1]->set({name=>"Photo Test, add Gallery, Album and 1 Photo"});
|
|||
|
||||
$session->user( { userId => 3 } ); # Admins can do everything
|
||||
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
# Create a user for testing purposes
|
||||
my $user = WebGUI::User->new( $session, "new" );
|
||||
$user->username( 'dufresne' );
|
||||
$user->addToGroups( ['3'] );
|
||||
my $identifier = 'ritahayworth';
|
||||
my $auth = WebGUI::Operation::Auth::getInstance( $session, $user->authMethod, $user->userId );
|
||||
$auth->saveParams( $user->userId, $user->authMethod, {
|
||||
'identifier' => Digest::MD5::md5_base64( $identifier ),
|
||||
});
|
||||
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddFile => 3, # Admins
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
|
|
@ -61,67 +70,58 @@ $versionTags[-1]->commit;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan skip_all => "Tests are not working yet.";
|
||||
plan skip_all => "Tests not working yet";
|
||||
#plan tests => 1;
|
||||
|
||||
use_ok("Test::WWW::Mechanize");
|
||||
my $mech;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test permissions
|
||||
$mech = Test::WWW::Mechanize->new;
|
||||
|
||||
# Edit an existing photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_edit",
|
||||
userId => "1",
|
||||
test_privilege => "insufficient",
|
||||
})->run;
|
||||
$mech->get( $session->url->getSiteURL . $photo->getUrl("func=edit") );
|
||||
$mech->content_contains("permission denied");
|
||||
|
||||
$mech->get( $session->url->getSiteURL . $photo->getUrl("func=editSave") );
|
||||
$mech->content_contains("permission denied");
|
||||
|
||||
# Save a new photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_editSave",
|
||||
userId => "1",
|
||||
test_privilege => "insufficient",
|
||||
})->run;
|
||||
$mech->get( $session->url->getSiteURL . $album->getUrl("func=add;class=WebGUI::Asset::File::GalleryFile::Photo") );
|
||||
$mech->content_contains("permission denied");
|
||||
|
||||
$mech->get( $session->url->getSiteURL . $album->getUrl("func=editSave;assetId=new;class=WebGUI::Asset::File::GalleryFile::Photo") );
|
||||
$mech->content_contains("permission denied");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test processPropertiesFromFormPost errors
|
||||
# TODO: This test should use i18n.
|
||||
# TODO: This error / test should occur in File, not Photo
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_editSave",
|
||||
formParams => {
|
||||
assetId => "new",
|
||||
className => "WebGUI::Asset::File::GalleryFile::Photo",
|
||||
$mech = Test::WWW::Mechanize->new;
|
||||
# Login mech object
|
||||
$mech->get( $session->url->getSiteURL . '?op=auth;method=login;username=dufresne;identifier=ritahayworth' );
|
||||
|
||||
$mech->get_ok( $album->getUrl('func=add;class=WebGUI::Asset::File::GalleryFile::Photo') );
|
||||
$mech->submit_form(
|
||||
with_fields => {
|
||||
title => '',
|
||||
newFile_file => '',
|
||||
},
|
||||
test_regex => [
|
||||
qr/You must select a file/,
|
||||
qr/You must enter a title/,
|
||||
],
|
||||
})->run;
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test editSave success result
|
||||
# TODO: This test should use i18n
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_editSave",
|
||||
formParams => {
|
||||
assetId => "new",
|
||||
className => "WebGUI::Asset::File::GalleryFile::Photo",
|
||||
},
|
||||
test_regex => [
|
||||
qr/awaiting approval and commit/,
|
||||
],
|
||||
})->run;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$gallery->purge;
|
||||
foreach my $versionTag (@versionTags) {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
$user->delete;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use Scalar::Util qw( blessed );
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::GalleryFile::Photo;
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ $versionTag->commit;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 11;
|
||||
plan tests => 10;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeShortcut argument checking
|
||||
|
|
@ -76,7 +77,7 @@ ok(
|
|||
);
|
||||
|
||||
is(
|
||||
blessed $shortcut, "WebGUI::Asset::Shortcut",
|
||||
Scalar::Util::blessed($shortcut), "WebGUI::Asset::Shortcut",
|
||||
"Photo->makeShortcut returns a WebGUI::Shortcut asset",
|
||||
);
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ ok(
|
|||
);
|
||||
|
||||
is(
|
||||
blessed $shortcut, "WebGUI::Asset::Shortcut",
|
||||
Scalar::Util::blessed($shortcut), "WebGUI::Asset::Shortcut",
|
||||
"Photo->makeShortcut returns a WebGUI::Shortcut asset",
|
||||
);
|
||||
|
||||
|
|
@ -105,26 +106,15 @@ is(
|
|||
"Photo->makeShortcut makes a shortcut to the correct asset",
|
||||
);
|
||||
|
||||
SKIP: {
|
||||
skip "Asset::Shortcut does not have a getShortcutOverrides method", 1;
|
||||
is_deeply(
|
||||
{$shortcut->getShortcutOverrides}, $overrides,
|
||||
"Photo->makeShortcut makes a shortcut with the correct overrides",
|
||||
);
|
||||
}
|
||||
my %shortcutOverrides = $shortcut->getOverrides;
|
||||
cmp_deeply(
|
||||
{ map({ $_ => $shortcutOverrides{overrides}->{$_}->{newValue} } keys %{ $overrides }) },
|
||||
$overrides,
|
||||
"Photo->makeShortcut makes a shortcut with the correct overrides",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_makeShortcut is only available to those who can edit the photo
|
||||
SKIP: {
|
||||
skip "test_privilege has a bug", 1;
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_makeShortcut",
|
||||
userId => 1,
|
||||
test_privilege => "insufficient",
|
||||
});
|
||||
$maker->run;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_makeShortcut
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ cmp_deeply(
|
|||
);
|
||||
|
||||
ok(
|
||||
-e $storage->getPath($gallery->get('imageResolutions') . '.jpg'),
|
||||
-e $storage->getPath($gallery->getImageResolutions->[0] . '.jpg'),
|
||||
"Generated resolution file exists on the filesystem",
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Scalar::Util qw( blessed );
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use Test::Deep;
|
||||
use WebGUI::Asset::File::GalleryFile::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -27,10 +27,11 @@ my $session = WebGUI::Test->session;
|
|||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 7, # Everyone
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
|
|
@ -44,6 +45,7 @@ my $album
|
|||
my $photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::GalleryFile::Photo",
|
||||
ownerUserId => 3,
|
||||
},
|
||||
undef,
|
||||
undef,
|
||||
|
|
@ -57,10 +59,47 @@ $photo->setFile( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
|||
# Tests
|
||||
plan tests => 1;
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Write some tests";
|
||||
ok(0, 'No tests here, move on');
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getTemplateVars
|
||||
$session->user( { userId => 1 } );
|
||||
my $testTemplateVars = {
|
||||
%{ $photo->get },
|
||||
synopsis => '', # Synopsis is not undef, is changed to empty string
|
||||
canComment => bool( 1 ),
|
||||
canEdit => bool( 0 ),
|
||||
ownerUsername => WebGUI::User->new( $session, 3 )->username,
|
||||
url => $photo->getUrl,
|
||||
url_addArchive => $album->getUrl('func=addArchive'),
|
||||
url_delete => $photo->getUrl('func=delete'),
|
||||
url_demote => $photo->getUrl('func=demote'),
|
||||
url_edit => $photo->getUrl('func=edit'),
|
||||
url_gallery => $gallery->getUrl,
|
||||
url_makeShortcut => $photo->getUrl('func=makeShortcut'),
|
||||
url_listFilesForOwner
|
||||
=> $gallery->getUrl('func=listFilesForUser;userId=3'),
|
||||
url_promote => $photo->getUrl('func=promote'),
|
||||
fileUrl => $photo->getFileUrl,
|
||||
thumbnailUrl => $photo->getThumbnailUrl,
|
||||
numberOfComments => scalar @{ $photo->getCommentIds },
|
||||
resolutions_loop => ignore(), # Tested elsewhere
|
||||
exifLoop => ignore(), # Tested elsewhere
|
||||
# Gallery stuff
|
||||
url_search => $gallery->getUrl('func=search'),
|
||||
url_listFilesForCurrentUser => $gallery->getUrl('func=listFilesForUser'),
|
||||
|
||||
};
|
||||
# Ignore all EXIF tags
|
||||
for my $tag ( keys %{ $photo->getExifData } ) {
|
||||
$testTemplateVars->{ 'exif_' . $tag } = ignore();
|
||||
}
|
||||
# Add search vars
|
||||
$gallery->appendTemplateVarsSearchForm( $testTemplateVars );
|
||||
|
||||
cmp_deeply(
|
||||
$photo->getTemplateVars,
|
||||
$testTemplateVars,
|
||||
"getTemplateVars is correct and complete",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
|
|
|
|||
|
|
@ -51,7 +51,13 @@ isa_ok(
|
|||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
# Test adding children to Gallery
|
||||
|
||||
# Only GalleryAlbums may be added
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a gallery
|
||||
my $properties = $gallery->get;
|
||||
$gallery->purge;
|
||||
|
||||
|
|
|
|||
83
t/Asset/Wobject/Gallery/permission.t
Normal file
83
t/Asset/Wobject/Gallery/permission.t
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 permissions inside Gallerys
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Gallery Test"});
|
||||
my $maker = WebGUI::Test::Maker::Permission->new;
|
||||
my $gallery;
|
||||
|
||||
my $nonAdmin = WebGUI::User->new( $session, "new" );
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
# Plan is delayed until all tests are prepared
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Gallery',
|
||||
groupIdAddComment => '7', # Everyone
|
||||
groupIdAddFile => '2', # Registered Users
|
||||
groupIdEdit => '3', # Admins
|
||||
groupIdView => '7', # Everyone
|
||||
ownerUserId => '3', # Admin
|
||||
});
|
||||
|
||||
$maker->prepare(
|
||||
{
|
||||
object => $gallery,
|
||||
method => "canView",
|
||||
pass => [ '1', '3', $nonAdmin->userId ],
|
||||
},
|
||||
{
|
||||
object => $gallery,
|
||||
method => 'canEdit',
|
||||
pass => [ '3' ],
|
||||
fail => [ '1', $nonAdmin->userId ],
|
||||
},
|
||||
{
|
||||
object => $gallery,
|
||||
method => 'canAddFile',
|
||||
pass => [ '3', $nonAdmin->userId ],
|
||||
fail => [ '1' ],
|
||||
},
|
||||
{
|
||||
object => $gallery,
|
||||
method => 'canComment',
|
||||
pass => [ '1', '3', $nonAdmin->userId ],
|
||||
}
|
||||
);
|
||||
|
||||
plan tests => $maker->plan;
|
||||
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ $versionTag->commit;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the addArchive sub
|
||||
|
|
@ -65,11 +65,30 @@ cmp_deeply(
|
|||
bag( "Aana1.jpg", "Aana2.jpg", "Aana3.jpg" ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
[ map { $_->get("title") } @$images ],
|
||||
bag( "Aana1", "Aana2", "Aana3" ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
[ map { $_->get("menuTitle") } @$images ],
|
||||
bag( "Aana1", "Aana2", "Aana3" ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
[ map { $_->get("url") } @$images ],
|
||||
bag(
|
||||
$session->url->urlize( $album->getUrl . "/Aana1" ),
|
||||
$session->url->urlize( $album->getUrl . "/Aana2" ),
|
||||
$session->url->urlize( $album->getUrl . "/Aana3" ),
|
||||
),
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the www_addArchive page
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
$versionTag->rollback;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ use Scalar::Util qw( blessed );
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use Test::Deep;
|
||||
use XML::Simple;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
|
|
@ -41,6 +41,7 @@ my $album
|
|||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
description => "An RSS Description",
|
||||
},
|
||||
undef,
|
||||
undef,
|
||||
|
|
@ -53,6 +54,7 @@ for my $i ( 0 .. 5 ) {
|
|||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::GalleryFile::Photo",
|
||||
filename => "$i.jpg",
|
||||
synopsis => "This is a description for $i.jpg",
|
||||
},
|
||||
undef,
|
||||
undef,
|
||||
|
|
@ -65,15 +67,38 @@ $versionTag->commit;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 1;
|
||||
plan tests => 2;
|
||||
|
||||
use_ok("Test::WWW::Mechanize");
|
||||
my $mech;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_viewRss
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Write some tests";
|
||||
ok(0, "No tests here");
|
||||
}
|
||||
$mech = Test::WWW::Mechanize->new;
|
||||
my $url = $session->url->getSiteURL . $session->url->makeAbsolute( $album->getUrl('func=viewRss') );
|
||||
$mech->get( $url );
|
||||
cmp_deeply(
|
||||
XMLin( $mech->content ),
|
||||
{
|
||||
version => '2.0',
|
||||
channel => {
|
||||
link => $session->url->getSiteURL . $album->getUrl,
|
||||
description => $album->get("description"),
|
||||
title => $album->get("title"),
|
||||
item => bag(
|
||||
map {
|
||||
superhashof({
|
||||
link => $session->url->getSiteURL . $_->getUrl,
|
||||
title => $_->get("title"),
|
||||
pubDate => $session->datetime->epochToMail( $_->get("revisionDate") ),
|
||||
description => $_->get("synopsis"),
|
||||
})
|
||||
} @photos
|
||||
),
|
||||
},
|
||||
},
|
||||
"RSS Datastructure is complete and correct",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
|
|
|
|||
|
|
@ -21,26 +21,31 @@ use Test::More; # increment this value for each test you create
|
|||
my $session = WebGUI::Test->session;
|
||||
|
||||
my @testSets = (
|
||||
{
|
||||
input => ['none', 'Asset'],
|
||||
output => q!None!,
|
||||
comment => q|explicit namespace|,
|
||||
},
|
||||
{
|
||||
input => ['change url', 'Asset'],
|
||||
output => q!Change URL!,
|
||||
comment => q|space in label|,
|
||||
},
|
||||
{
|
||||
input => ['webgui', 'WebGUI'],
|
||||
output => q!WebGUI!,
|
||||
comment => q|explicit namespace #2|,
|
||||
},
|
||||
{
|
||||
input => ['webgui', ''],
|
||||
output => q!WebGUI!,
|
||||
comment => q|default namespace|,
|
||||
},
|
||||
{
|
||||
input => ['none', 'Asset'],
|
||||
output => q!None!,
|
||||
comment => q|explicit namespace|,
|
||||
},
|
||||
{
|
||||
input => ['change url', 'Asset'],
|
||||
output => q!Change URL!,
|
||||
comment => q|space in label|,
|
||||
},
|
||||
{
|
||||
input => ['webgui', 'WebGUI'],
|
||||
output => q!WebGUI!,
|
||||
comment => q|explicit namespace #2|,
|
||||
},
|
||||
{
|
||||
input => ['webgui', ''],
|
||||
output => q!WebGUI!,
|
||||
comment => q|default namespace|,
|
||||
},
|
||||
{
|
||||
input => ['template listFilesForUser title', 'Asset_Gallery', 'plainblack'],
|
||||
output => q{plainblack's Gallery},
|
||||
comment => q{Third and more arguments are passed to sprintf()},
|
||||
},
|
||||
);
|
||||
|
||||
my $numTests = scalar @testSets;
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@
|
|||
|
||||
use strict;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../../../../../lib";
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Test;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
|
|
@ -132,7 +131,7 @@ plan tests => 10
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test use
|
||||
my $utility = 'WebGUI::Asset::Wobject::Gallery::Utility';
|
||||
my $utility = 'WebGUI::Utility::Gallery';
|
||||
use_ok($utility);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
Loading…
Add table
Add a link
Reference in a new issue