Finished? Ready for merge at least.
This commit is contained in:
parent
5d1faff793
commit
82e9bf8448
45 changed files with 5112 additions and 513 deletions
78
t/Asset/Wobject/Gallery/00base.t
Normal file
78
t/Asset/Wobject/Gallery/00base.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 creation and deletion of album assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating an album
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
"Album is a WebGUI::Asset::Wobject::GalleryAlbum object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$album, "WebGUI::Asset::Wobject",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
my $properties = $album->get;
|
||||
$album->purge;
|
||||
|
||||
is(
|
||||
$album, undef,
|
||||
"Album is undefined",
|
||||
);
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Album no longer able to be instanciated",
|
||||
);
|
||||
|
||||
96
t/Asset/Wobject/Gallery/delete.t
Normal file
96
t/Asset/Wobject/Gallery/delete.t
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# $vim: syntax=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 deleting of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete page gives error for those who can't edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
}, {
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete confirm page appears for those allowed to edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_regex => [ qr/func=deleteConfirm/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_deleteConfirm deletes the asset
|
||||
my $assetId = $album->getId;
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_regex => [ qr/has been deleted/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass( $session, $assetId ),
|
||||
undef,
|
||||
"GalleryAlbum cannot be instanciated after www_deleteConfirm",
|
||||
);
|
||||
|
||||
78
t/Asset/Wobject/Gallery/listFilesForUser.t
Normal file
78
t/Asset/Wobject/Gallery/listFilesForUser.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 creation and deletion of album assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating an album
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
"Album is a WebGUI::Asset::Wobject::GalleryAlbum object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$album, "WebGUI::Asset::Wobject",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
my $properties = $album->get;
|
||||
$album->purge;
|
||||
|
||||
is(
|
||||
$album, undef,
|
||||
"Album is undefined",
|
||||
);
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Album no longer able to be instanciated",
|
||||
);
|
||||
|
||||
107
t/Asset/Wobject/Gallery/permission.t
Normal file
107
t/Asset/Wobject/Gallery/permission.t
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 permissions of GalleryAlbum assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Permission->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my %user;
|
||||
$user{"2"} = WebGUI::User->new( $session, "new" );
|
||||
$user{"2"}->addToGroups( ['2'] ); # Registered user
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
$user{"2"}->delete;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# By default, GalleryAlbum inherits its permissions from the Gallery, but
|
||||
# only the owner of the GalleryAlbum is allowed to add files
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canView",
|
||||
pass => [ 1, 3, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canEdit",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddComment",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbums with "allowComments" false do not allow anyone to comment
|
||||
$album->update({ allowComments => 0 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canComment",
|
||||
fail => [ 1, 3, $user{"2"}, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbum with "othersCanAdd" true allows anyone who can add files to
|
||||
# the Gallery to add files to this GalleryAlbum
|
||||
$album->update({ othersCanAdd => 1 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
66
t/Asset/Wobject/Gallery/rss.t
Normal file
66
t/Asset/Wobject/Gallery/rss.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# $vim: syntax=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 rss view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_viewRss
|
||||
|
||||
78
t/Asset/Wobject/Gallery/search.t
Normal file
78
t/Asset/Wobject/Gallery/search.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 creation and deletion of album assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating an album
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
"Album is a WebGUI::Asset::Wobject::GalleryAlbum object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$album, "WebGUI::Asset::Wobject",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
my $properties = $album->get;
|
||||
$album->purge;
|
||||
|
||||
is(
|
||||
$album, undef,
|
||||
"Album is undefined",
|
||||
);
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Album no longer able to be instanciated",
|
||||
);
|
||||
|
||||
130
t/Asset/Wobject/Gallery/view.t
Normal file
130
t/Asset/Wobject/Gallery/view.t
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
# $vim: syntax=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 default view and associated subs
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 2, # Registered Users
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getFileIds and getFilePaginator
|
||||
cmp_bag( $album->getFileIds, [ map { $_->getId } @photos ] );
|
||||
|
||||
my $p = $album->getFilePaginator;
|
||||
isa_ok( $p, "WebGUI::Paginator" );
|
||||
cmp_deeply( $p->getPageData, subbagof( map { $_->getId } @photos ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getTemplateVars
|
||||
|
||||
# Is a superset of Asset->get
|
||||
# NOTE: url is Asset->getUrl
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( { %{$album->get}, url => $album->getUrl, } ) );
|
||||
|
||||
# Contains specific keys/values
|
||||
my $expected = {
|
||||
"url_addPhoto"
|
||||
=> all(
|
||||
re( qr/className=WebGUI::Asset::File::Image::Photo/ ),
|
||||
re( qr/func=add/ ),
|
||||
re( $album->getUrl ),
|
||||
),
|
||||
"url_addNoClass"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=add$/ ),
|
||||
),
|
||||
"url_slideshow"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=slideshow/ ),
|
||||
),
|
||||
"url_thumbnails"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=thumbnails/ ),
|
||||
),
|
||||
"url_viewRss"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=viewRss/ ),
|
||||
),
|
||||
};
|
||||
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( $expected ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsFileLoop
|
||||
$expected = {
|
||||
"file_loop" => bag( map { $_->getTemplateVars } @photos ),
|
||||
};
|
||||
cmp_deeply(
|
||||
$album->appendTemplateVarsFileLoop({},$self->getFilePaginator->getPageData),
|
||||
$expected
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_view() for those without permission to view
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_view",
|
||||
test_privilege => "insufficient",
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
69
t/Asset/Wobject/GalleryAlbum/addArchive.t
Normal file
69
t/Asset/Wobject/GalleryAlbum/addArchive.t
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# $vim: syntax=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 permissions of GalleryAlbum assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Permission->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the addArchive sub
|
||||
# elephant_images.zip contains three jpgs: Aana1.jpg, Aana2.jpg, Aana3.jpg
|
||||
$album->addArchive( WebGUI::Test->getTestCollateralPath('elephant_images.zip') );
|
||||
my $images = $album->getLineage(['descendants'], { returnObjects => 1 });
|
||||
|
||||
is( scalar @$images, 3, "addArchive() adds one asset per image" );
|
||||
cmp_deeply(
|
||||
[ map { $_->get("filename") } @$images ],
|
||||
bag( "Aana1.jpg", "Aana2.jpg", "Aana3.jpg" ),
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the www_addArchive page
|
||||
96
t/Asset/Wobject/GalleryAlbum/delete.t
Normal file
96
t/Asset/Wobject/GalleryAlbum/delete.t
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# $vim: syntax=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 deleting of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete page gives error for those who can't edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
}, {
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete confirm page appears for those allowed to edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_regex => [ qr/func=deleteConfirm/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_deleteConfirm deletes the asset
|
||||
my $assetId = $album->getId;
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_regex => [ qr/has been deleted/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass( $session, $assetId ),
|
||||
undef,
|
||||
"GalleryAlbum cannot be instanciated after www_deleteConfirm",
|
||||
);
|
||||
|
||||
107
t/Asset/Wobject/GalleryAlbum/permission.t
Normal file
107
t/Asset/Wobject/GalleryAlbum/permission.t
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 permissions of GalleryAlbum assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Permission->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my %user;
|
||||
$user{"2"} = WebGUI::User->new( $session, "new" );
|
||||
$user{"2"}->addToGroups( ['2'] ); # Registered user
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
$user{"2"}->delete;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# By default, GalleryAlbum inherits its permissions from the Gallery, but
|
||||
# only the owner of the GalleryAlbum is allowed to add files
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canView",
|
||||
pass => [ 1, 3, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canEdit",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddComment",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbums with "allowComments" false do not allow anyone to comment
|
||||
$album->update({ allowComments => 0 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canComment",
|
||||
fail => [ 1, 3, $user{"2"}, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbum with "othersCanAdd" true allows anyone who can add files to
|
||||
# the Gallery to add files to this GalleryAlbum
|
||||
$album->update({ othersCanAdd => 1 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
66
t/Asset/Wobject/GalleryAlbum/rss.t
Normal file
66
t/Asset/Wobject/GalleryAlbum/rss.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# $vim: syntax=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 rss view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_viewRss
|
||||
|
||||
69
t/Asset/Wobject/GalleryAlbum/slideshow.t
Normal file
69
t/Asset/Wobject/GalleryAlbum/slideshow.t
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# $vim: syntax=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 slideshow view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test view_slideshow
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_slideshow
|
||||
|
||||
69
t/Asset/Wobject/GalleryAlbum/thumbnails.t
Normal file
69
t/Asset/Wobject/GalleryAlbum/thumbnails.t
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# $vim: syntax=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 thumbnails view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test view_thumbnails
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_thumbnails
|
||||
|
||||
132
t/Asset/Wobject/GalleryAlbum/view.t
Normal file
132
t/Asset/Wobject/GalleryAlbum/view.t
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
# $vim: syntax=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 default view and associated subs
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 2, # Registered Users
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getFileIds and getFilePaginator
|
||||
cmp_bag( $album->getFileIds, [ map { $_->getId } @photos ] );
|
||||
|
||||
my $p = $album->getFilePaginator;
|
||||
isa_ok( $p, "WebGUI::Paginator" );
|
||||
cmp_deeply( $p->getPageData, subbagof( map { $_->getId } @photos ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getTemplateVars
|
||||
|
||||
# Is a superset of Asset->get
|
||||
# NOTE: url is Asset->getUrl
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( { %{$album->get}, url => $album->getUrl, } ) );
|
||||
|
||||
# Contains specific keys/values
|
||||
my $expected = {
|
||||
"url_addPhoto"
|
||||
=> all(
|
||||
re( qr/className=WebGUI::Asset::File::Image::Photo/ ),
|
||||
re( qr/func=add/ ),
|
||||
re( $album->getUrl ),
|
||||
),
|
||||
"url_addNoClass"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=add$/ ),
|
||||
),
|
||||
"url_slideshow"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=slideshow/ ),
|
||||
),
|
||||
"url_thumbnails"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=thumbnails/ ),
|
||||
),
|
||||
"url_viewRss"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=viewRss/ ),
|
||||
),
|
||||
"ownerUsername"
|
||||
=> WebGUI::User->new($session, 3)->username,
|
||||
};
|
||||
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( $expected ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsFileLoop
|
||||
$expected = {
|
||||
"file_loop" => bag( map { $_->getTemplateVars } @photos ),
|
||||
};
|
||||
cmp_deeply(
|
||||
$album->appendTemplateVarsFileLoop({},$self->getFilePaginator->getPageData),
|
||||
$expected
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_view() for those without permission to view
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_view",
|
||||
test_privilege => "insufficient",
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue