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;
|
||||
|
||||
104
t/Form.t
Normal file
104
t/Form.t
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
# 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";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 5; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the formHeader method
|
||||
|
||||
ok(
|
||||
!eval{ WebGUI::Form::formHeader( "" ); 1 },
|
||||
"formHeader() dies if first parameter is not WebGUI Session",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ WebGUI::Form::formHeader( $session, ['foo'] ); 1 },
|
||||
"formHeader() dies if second parameter is not hash reference",
|
||||
);
|
||||
|
||||
# Test the defaults for formHeader()
|
||||
my $testDefaults = all(
|
||||
re( q{<form[^>]*>} ),
|
||||
re( q{action=} ),
|
||||
re( q{enctype="multipart/form-data"} ),
|
||||
re( q{method="post"} ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
WebGUI::Form::formHeader( $session ),
|
||||
$testDefaults,
|
||||
"formHeader called without an options hashref",
|
||||
);
|
||||
|
||||
# Test options passed into formHeader()
|
||||
my $testWithOptions = all(
|
||||
re( q{<form[^>]*>} ),
|
||||
re( q{action="action"} ),
|
||||
re( q{enctype="enctype"} ),
|
||||
re( q{method="method"} ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
WebGUI::Form::formHeader( $session, {
|
||||
action => "action",
|
||||
enctype => "enctype",
|
||||
method => "method",
|
||||
} ),
|
||||
$testWithOptions,
|
||||
"formHeader called with an options hashref",
|
||||
);
|
||||
|
||||
# Test "action" option containing query parameters
|
||||
my $testHiddenElements = all(
|
||||
re( q{<input type="hidden" name="func" value="edit"} ),
|
||||
re( q{<input type="hidden" name="a" value="1"} ),
|
||||
re( q{<input type="hidden" name="b" value="2"} ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
WebGUI::Form::formHeader( $session, {
|
||||
action => "action?func=edit;a=1&b=2",
|
||||
}),
|
||||
$testHiddenElements,
|
||||
"formHeader 'action' option containing query parameters",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Some things on the TODO list";
|
||||
# Test the formFooter method
|
||||
# Test that the autohandler works properly
|
||||
}
|
||||
59
t/Form/SelectRichEditor.t
Normal file
59
t/Form/SelectRichEditor.t
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# $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 SelectRichEditor form control
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
|
||||
use WebGUI::Form::SelectRichEditor;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $root = WebGUI::Asset->getRoot( $session );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test that SelectRichEditor control contains all RichEdit assets.
|
||||
my $richEditAssets
|
||||
= $root->getLineage( ['descendants'], {
|
||||
returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::RichEdit'],
|
||||
});
|
||||
my $richEditOptions
|
||||
= {
|
||||
map { $_->getId => $_->get("title") } @$richEditAssets
|
||||
};
|
||||
|
||||
my $control
|
||||
= WebGUI::Form::SelectRichEditor->new( $session, { name => "richEditId" } );
|
||||
cmp_deeply(
|
||||
$control->get("options"),
|
||||
$richEditOptions,
|
||||
"SelectRichEditor control has options for all Rich Editors in this site",
|
||||
);
|
||||
10
t/Storage.t
10
t/Storage.t
|
|
@ -227,6 +227,16 @@ ok (-e $storage1->getPath("testfile-hash.file"), 'addFileFromHashRef creates fil
|
|||
my $thawedHash = $storage1->getFileContentsAsHashref('testfile-hash.file');
|
||||
cmp_deeply($storageHash, $thawedHash, 'getFileContentsAsHashref: thawed hash correctly');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# copyFile
|
||||
#
|
||||
####################################################
|
||||
|
||||
$storage1->copyFile("testfile-hash.file", "testfile-hash-copied.file");
|
||||
ok (-e $storage1->getPath("testfile-hash-copied.file"),'copyFile created file with new name');
|
||||
ok (-e $storage1->getPath("testfile-hash.file"), "copyFile original file still exists");
|
||||
|
||||
####################################################
|
||||
#
|
||||
# renameFile
|
||||
|
|
|
|||
|
|
@ -1,24 +1,40 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use WebGUI::Test;
|
||||
use Test::More;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Test;
|
||||
|
||||
# load your modules here
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
use Test::More tests => 1; # increment this value for each test you create
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 1; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ Create a new WebGUI::Test::Maker::HTML object.
|
|||
|
||||
Get a setting. Set L<set> for a list of settings.
|
||||
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 plan
|
||||
|
|
|
|||
|
|
@ -55,9 +55,13 @@ Test::More
|
|||
|
||||
Create a new WebGUI::Test::Maker::Permission object.
|
||||
|
||||
=cut
|
||||
|
||||
=head2 get
|
||||
|
||||
Get a setting. Set L<set> for a list of settings.
|
||||
Get a setting. See C<set> for a list of settings.
|
||||
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -116,11 +120,13 @@ The permissions method to test
|
|||
|
||||
=item pass
|
||||
|
||||
An array reference of userIds that should pass the permissions test.
|
||||
An array reference of userIds or WebGUI::User objects that should pass the
|
||||
permissions test.
|
||||
|
||||
=item fail
|
||||
|
||||
An array reference of userIds that should fail the permissions test.
|
||||
An array reference of userIds or WebGUI::User objects that should fail the
|
||||
permissions test.
|
||||
|
||||
=back
|
||||
|
||||
|
|
@ -146,6 +152,16 @@ sub prepare {
|
|||
croak("Couldn't prepare: Test $test_num, fail is not an array reference")
|
||||
if $test->{fail} && ref $test->{fail} ne "ARRAY";
|
||||
|
||||
# Make sure pass and fail arrayrefs are userIds
|
||||
for my $array ( $test->{pass, fail} ) {
|
||||
for ( my $i = 0; $i < @$array; $i++ ) {
|
||||
# If is a User object, replace with userId
|
||||
if ( blessed $array->[$i] && $array->[$i]->isa("WebGUI::User") ) {
|
||||
$array->[$i] = $array->[$i]->userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
push @{$self->{_tests}}, $test;
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
t/supporting_collateral/elephant_images.zip
Normal file
BIN
t/supporting_collateral/elephant_images.zip
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue