re-integrated photogallery branch
This commit is contained in:
commit
4c70aa4c71
75 changed files with 10806 additions and 473 deletions
|
|
@ -26,6 +26,8 @@ use Test::More; # increment this value for each test you create
|
|||
use Test::Deep;
|
||||
plan tests => 9;
|
||||
|
||||
#TODO: This script tests certain aspects of WebGUI::Storage and it should not
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
##Create a storage location
|
||||
|
|
|
|||
83
t/Asset/File/Image/Photo/00base.t
Normal file
83
t/Asset/File/Image/Photo/00base.t
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of photo 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=>"Photo Test"});
|
||||
print "hi";
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::File::Image::Photo");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating a photo
|
||||
my $photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $photo, "WebGUI::Asset::File::Image::Photo",
|
||||
"Photo is a WebGUI::Asset::File::Image::Photo object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$photo, "WebGUI::Asset::File::Image",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $photo->getGallery, "WebGUI::Asset::Wobject::Gallery",
|
||||
"Photo->getGallery gets the gallery containing this photo",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a photo
|
||||
my $properties = $photo->get;
|
||||
$photo->purge;
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Photo no longer able to be instanciated",
|
||||
);
|
||||
|
||||
53
t/Asset/File/Image/Photo/ajax.t
Normal file
53
t/Asset/File/Image/Photo/ajax.t
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the AJAX methods of the Photo asset
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
|
||||
250
t/Asset/File/Image/Photo/comment.t
Normal file
250
t/Asset/File/Image/Photo/comment.t
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 adding, deleting, editing, and
|
||||
# getting comments for photos
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
groupIdAddComment => "2",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test with no comments
|
||||
is(
|
||||
blessed $photo->getCommentPaginator, "WebGUI::Paginator",
|
||||
"Photo with no comments still provides comments paginator",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$photo->getCommentIds, [],
|
||||
"Photo->getCommentIds returns an empty arrayref when no comments",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the setComment requires two arguments
|
||||
ok(
|
||||
!eval{ $photo->setComment(); 1 },
|
||||
"Photo->setComment fails when no arguments given",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->setComment("new"); 1 },
|
||||
"Photo->setComment fails when no second argument given",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->setComment("new", "lulz"); 1 },
|
||||
"Photo->setComment fails when second argument is not a hashref",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->setComment("new", { lulz => "ohai" }); 1 },
|
||||
"Photo->setComment fails when hashref does not contain a bodyText key",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test adding a comment
|
||||
# - bodyText is defined
|
||||
# - All else is defaults
|
||||
my $commentId;
|
||||
ok(
|
||||
eval{ $commentId = $photo->setComment("new", { bodyText => "bodyText", }); 1 },
|
||||
"Photo->setComment succeeds",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$photo->getCommentIds, [$commentId],
|
||||
"Photo->getCommentIds returns newly added comment's ID",
|
||||
);
|
||||
|
||||
my $comment;
|
||||
ok(
|
||||
eval{ $comment = $photo->getComment($commentId); 1},
|
||||
"Photo->getComment does not croak.",
|
||||
);
|
||||
|
||||
is(
|
||||
ref $comment, "HASH",
|
||||
"Photo->getComment returns a hash reference",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{assetId}, $photo->getId,
|
||||
"Comment has correct assetId",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{userId}, $session->user->userId,
|
||||
"Comment has correct userId",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{visitorIp}, undef,
|
||||
"visitorIp is not defined if the user is not a visitor",
|
||||
);
|
||||
|
||||
like(
|
||||
$comment->{creationDate}, /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/,
|
||||
"creationDate is defined and is a MySQL-formatted date",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test adding a comment
|
||||
# - bodyText is defined
|
||||
# - userId is visitor
|
||||
# - all else is defaults
|
||||
ok(
|
||||
eval{ $commentId = $photo->setComment("new", { userId => 1, bodyText => "bodyText", }); 1 },
|
||||
"Photo->setComment succeeds",
|
||||
);
|
||||
|
||||
ok(
|
||||
grep { $_ eq $commentId } @{ $photo->getCommentIds },
|
||||
"Photo->getCommentIds returns newly added comment's ID",
|
||||
);
|
||||
|
||||
my $comment;
|
||||
ok(
|
||||
eval{ $comment = $photo->getComment($commentId); 1},
|
||||
"Photo->getComment does not croak.",
|
||||
);
|
||||
|
||||
is(
|
||||
ref $comment, "HASH",
|
||||
"Photo->getComment returns a hash reference",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{assetId}, $photo->getId,
|
||||
"Comment has correct assetId",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{userId}, 1,
|
||||
"Comment has correct userId",
|
||||
);
|
||||
|
||||
ok(
|
||||
$comment->{visitorIp},
|
||||
"visitorIp is defined since user is visitor",
|
||||
);
|
||||
|
||||
like(
|
||||
$comment->{creationDate}, /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/,
|
||||
"creationDate is defined and is a MySQL-formatted date",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting comment
|
||||
$photo->deleteComment($commentId);
|
||||
ok(
|
||||
!grep { $_ eq $commentId } @{ $photo->getCommentIds },
|
||||
"Photo->getCommentIds no longer contains deleted comment",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting asset deletes comments
|
||||
my $assetId = $photo->getId;
|
||||
$photo->purge;
|
||||
ok(
|
||||
!$session->db->quickScalar("SELECT commentId FROM Photo_comment WHERE assetId=?",[$assetId]),
|
||||
"Comments are purged along with asset",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsForCommentForm
|
||||
TODO: {
|
||||
local $TODO = "Test appendTemplateVarsForCommentForm";
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_addCommentSave page sanity checks
|
||||
my $html;
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
# Permissions
|
||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||
userId => 1,
|
||||
formParams => { bodyText => "yes?" },
|
||||
});
|
||||
|
||||
like(
|
||||
$html, qr/permission denied/i,
|
||||
"www_addCommentSave -- Permission denied if not Gallery->canAddComment",
|
||||
);
|
||||
|
||||
# Required fields
|
||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||
userId => 2,
|
||||
formParams => { },
|
||||
});
|
||||
|
||||
like(
|
||||
$html, WebGUI::International->get($session, "Asset_Photo", "www_addCommentSave error missing required"),
|
||||
"www_addCommentSave -- Must have bodyText defined",
|
||||
);
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_addCommentSave functionality
|
||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||
userId => 2,
|
||||
formParams => { bodyText => "YES!", },
|
||||
});
|
||||
|
||||
like(
|
||||
$html, WebGUI::International->get($session, "Asset_Photo", "www_addCommentSave success"),
|
||||
"www_addCommentSave -- page shows success message",
|
||||
);
|
||||
|
||||
my $ids = $photo->getCommentIds;
|
||||
is(
|
||||
scalar @$ids, 1,
|
||||
"www_addCommentSave -- Comment was added",
|
||||
);
|
||||
53
t/Asset/File/Image/Photo/delete.t
Normal file
53
t/Asset/File/Image/Photo/delete.t
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the www_delete() and www_deleteConfirm()
|
||||
# methods
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
52
t/Asset/File/Image/Photo/download.t
Normal file
52
t/Asset/File/Image/Photo/download.t
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to get sthe getDownloadFileUrl and www_download()
|
||||
# methods
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
107
t/Asset/File/Image/Photo/editSave.t
Normal file
107
t/Asset/File/Image/Photo/editSave.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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the editSave,
|
||||
# processPropertiesFromFormPost, and applyConstraints methods.
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
$session->user( { userId => 3 } ); # Admins can do everything
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test permissions
|
||||
|
||||
# Edit an existing photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_edit",
|
||||
userId => "1",
|
||||
test_privilege => "insufficient",
|
||||
})->run;
|
||||
|
||||
# Save a new photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_editSave",
|
||||
userId => "1",
|
||||
test_privilege => "insufficient",
|
||||
})->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test processPropertiesFromFormPost errors
|
||||
# TODO: This test should use i18n.
|
||||
# TODO: This error / test should occur in File, not Photo
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_editSave",
|
||||
formParams => {
|
||||
assetId => "new",
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
},
|
||||
test_regex => [
|
||||
qr/You must select a file/,
|
||||
qr/You must enter a title/,
|
||||
],
|
||||
})->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test editSave success result
|
||||
# TODO: This test should use i18n
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_editSave",
|
||||
formParams => {
|
||||
assetId => "new",
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
},
|
||||
test_regex => [
|
||||
qr/awaiting approval and commit/,
|
||||
],
|
||||
})->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
79
t/Asset/File/Image/Photo/exif.t
Normal file
79
t/Asset/File/Image/Photo/exif.t
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the EXIF functionality of WebGUI's photo
|
||||
# asset
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use JSON;
|
||||
use Image::ExifTool;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
my ( $photo );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test that exif data gets parsed from the file
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->setFile( WebGUI::Test->getTestCollateralPath("lamp.jpg") );
|
||||
my $exifData = $photo->get("exifData");
|
||||
|
||||
ok( defined $exifData, "exifData column is defined after setFile" );
|
||||
|
||||
my $exif = jsonToObj( $exifData );
|
||||
ok( ref $exif eq "HASH", "exifData is JSON hash" );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getTemplateVars exif data
|
||||
my $var = $photo->getTemplateVars;
|
||||
|
||||
is_deeply(
|
||||
[ sort keys %$exif ],
|
||||
[ sort map { s/exif_// } keys %$var ],
|
||||
"getTemplateVars gets a hash of all exif tags",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort keys %$exif ],
|
||||
[ sort map { $_->{tag} } @{ $var->{exifLoop} } ],
|
||||
"getTemplateVars gets a loop over the tags",
|
||||
);
|
||||
203
t/Asset/File/Image/Photo/makeResolutions.t
Normal file
203
t/Asset/File/Image/Photo/makeResolutions.t
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 of photo download
|
||||
# resolutions
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
my $graphicsClass;
|
||||
BEGIN {
|
||||
if (eval { require Graphics::Magick; 1 }) {
|
||||
$graphicsClass = 'Graphics::Magick';
|
||||
}
|
||||
elsif (eval { require Image::Magick; 1 }) {
|
||||
$graphicsClass = 'Image::Magick';
|
||||
}
|
||||
}
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
|
||||
my ($gallery, $album, $photo);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Photo not added under a Photo Gallery asset does NOT generate any
|
||||
# default resolutions
|
||||
$photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(); 1 },
|
||||
"makeResolutions succeeds when photo not under photo gallery and no resolutions to make",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$photo->getStorageLocation->getFiles, ['page_title.jpg'],
|
||||
"makeResolutions does not make any extra resolutions when photo not under photo gallery",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeResolutions allows API to specify resolutions to make as array reference
|
||||
# argument
|
||||
$photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeResolutions('100x100','200x200'); 1 },
|
||||
"makeResolutions fails when first argument is not array reference",
|
||||
);
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(['100x100','200x200']); 1 },
|
||||
"makeResolutions succeeds when first argument is array reference of resolutions to make",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
['100x100.jpg', '200x200.jpg', 'page_title.jpg'],
|
||||
"makeResolutions makes all the required resolutions with the appropriate names.",
|
||||
);
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Test to ensure the files are created with correct resolution and density';
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeResolutions throws a warning on an invalid resolution but keeps going
|
||||
$photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
{ # localize our signal handler
|
||||
my @warnings;
|
||||
local $SIG{__WARN__} = sub { push @warnings, $_[0]; };
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(['abc','200','3d400']); 1 },
|
||||
"makeResolutions succeeds when invalid resolutions are given",
|
||||
);
|
||||
|
||||
is(
|
||||
scalar @warnings, 2,
|
||||
"makeResolutions throws a warning for each invalid resolution given",
|
||||
);
|
||||
|
||||
like(
|
||||
$warnings[0], qr/abc/,
|
||||
"makeResolutions throws a warning for the correct invalid resolution 'abc'",
|
||||
);
|
||||
|
||||
like(
|
||||
$warnings[1], qr/3d400/,
|
||||
"makeResolutions throws a warning for the correct invalid resolution '3d400'",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
['200.jpg', 'page_title.jpg'],
|
||||
"makeResolutions still makes valid resolutions when invalid resolutions given",
|
||||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeResolutions gets default resolutions from a parent Photo Gallery asset
|
||||
$gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
imageResolutions => "1600x1200\n1024x768\n800x600\n640x480",
|
||||
});
|
||||
$album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions; 1 },
|
||||
"makeResolutions succeeds when photo under photo gallery and no resolution given",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
[ '1024x768.jpg', '1600x1200.jpg', '640x480.jpg', '800x600.jpg', 'page_title.jpg' ],
|
||||
"makeResolutions makes all the required resolutions with the appropriate names.",
|
||||
);
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Test to ensure the files are created with correct resolution and density';
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Array of resolutions passed to makeResolutions overrides defaults from
|
||||
# parent asset
|
||||
$gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
imageResolutions => "1600x1200\n1024x768\n800x600\n640x480",
|
||||
});
|
||||
$album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeResolutions('100x100','200x200'); 1 },
|
||||
"makeResolutions fails when first argument is not array reference",
|
||||
);
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(['100x100','200x200']); 1 },
|
||||
"makeResolutions succeeds when first argument is array reference of resolutions to make",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
['100x100.jpg', '200x200.jpg', 'page_title.jpg'],
|
||||
"makeResolutions makes all the required resolutions with the appropriate names.",
|
||||
);
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Test to ensure the files are created with correct resolution and density';
|
||||
}
|
||||
|
||||
123
t/Asset/File/Image/Photo/makeShortcut.t
Normal file
123
t/Asset/File/Image/Photo/makeShortcut.t
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the makeShortcut method and www_makeShortcut
|
||||
# pages
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $otherParent
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Layout",
|
||||
});
|
||||
my $photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
userDefined1 => "ORIGINAL",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeShortcut argument checking
|
||||
ok(
|
||||
!eval{ $photo->makeShortcut(); 1 },
|
||||
"Photo->makeShortcut requires at least one argument",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeShortcut("", ""); 1},
|
||||
"Photo->makeShortcut fails if second argument is not hash reference",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeShortcut(""); 1},
|
||||
"Photo->makeShortcut fails if given parent cannot be instanciated",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeShortcut returns a reference to the new Shortcut asset
|
||||
my $shortcut;
|
||||
ok(
|
||||
eval{ $shortcut = $photo->makeShortcut($otherParent->getId); 1},
|
||||
"Photo->makeShortcut succeeds when valid assetId is given",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $shortcut, "WebGUI::Asset::Shortcut",
|
||||
"Photo->makeShortcut returns a WebGUI::Shortcut asset",
|
||||
);
|
||||
|
||||
is(
|
||||
$shortcut->getShortcutOriginal->getId, $photo->getId,
|
||||
"Photo->makeShortcut makes a shortcut to the correct asset",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeShortcut creates the appropriate overrides
|
||||
my $overrides = {
|
||||
userDefined1 => "OVERRIDDEN",
|
||||
};
|
||||
ok(
|
||||
eval{ $shortcut = $photo->makeShortcut($otherParent->getId, $overrides); 1},
|
||||
"Photo->makeShortcut succeeds when valid assetId is given",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $shortcut, "WebGUI::Asset::Shortcut",
|
||||
"Photo->makeShortcut returns a WebGUI::Shortcut asset",
|
||||
);
|
||||
|
||||
is(
|
||||
$shortcut->getShortcutOriginal->getId, $photo->getId,
|
||||
"Photo->makeShortcut makes a shortcut to the correct asset",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
{$shortcut->getShortcutOverrides}, $overrides,
|
||||
"Photo->makeShortcut makes a shortcut with the correct overrides",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_makeShortcut is only available to those who can edit the photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_makeShortcut",
|
||||
userId => 1,
|
||||
test_privilege => "insufficient",
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_makeShortcut
|
||||
135
t/Asset/File/Image/Photo/permissions.t
Normal file
135
t/Asset/File/Image/Photo/permissions.t
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# Test permissions of Photo assets
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Friends;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my ($photo);
|
||||
$session->user({ userId => 3 });
|
||||
|
||||
my $friend = WebGUI::User->new($session, "new");
|
||||
WebGUI::Friends->new($session)->add( [ $friend->userId ] );
|
||||
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdView => "7",
|
||||
groupIdEdit => "3",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
groupIdView => "",
|
||||
groupIdEdit => "",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
WebGUI::Friends->new($session)->delete( [ $friend->userId ] );
|
||||
$friend->delete;
|
||||
$versionTag->rollback;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Everyone can view, Admins can edit, Owned by current user
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdView => "7",
|
||||
groupIdEdit => "3",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
ok( $photo->canView(1), "Visitor can view" );
|
||||
ok( !$photo->canEdit(1), "Visitor cannot edit" );
|
||||
ok( $photo->canView(2), "Registered users can view" );
|
||||
ok( !$photo->canEdit(2), "Registered users cannot edit" );
|
||||
ok( $photo->canView, "Current user can view" );
|
||||
ok( $photo->canEdit, "Current user can edit" );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Admins can view, Admins can edit, Owned by Admin, current user is Visitor
|
||||
my $oldUser = $session->user;
|
||||
$session->user( { user => WebGUI::User->new($session, "1") } );
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdView => "3",
|
||||
groupIdEdit => "3",
|
||||
ownerUserId => "3",
|
||||
});
|
||||
|
||||
ok( !$photo->canView, "Visitors cannot view" );
|
||||
ok( !$photo->canEdit, "Visitors cannot edit" );
|
||||
ok( !$photo->canView(2), "Registered Users cannot view" );
|
||||
ok( !$photo->canEdit(2), "Registered Users cannot edit" );
|
||||
ok( $photo->canView(3), "Admins can view" );
|
||||
ok( $photo->canEdit(3), "Admins can edit" );
|
||||
$session->user( { user => $oldUser } );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Photo without specific view/edit inherits from gallery properties
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdView => "",
|
||||
groupIdEdit => "",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
ok( $photo->canView(1), "Visitors can view" );
|
||||
ok( !$photo->canEdit(1), "Visitors cannot edit" );
|
||||
ok( $photo->canView(2), "Registered Users can view" );
|
||||
ok( !$photo->canEdit(2), "Registered Users cannot edit" );
|
||||
ok( $photo->canView, "Owner can view" );
|
||||
ok( $photo->canEdit, "Owner can edit" );
|
||||
ok( $photo->canView(3), "Admin can view" );
|
||||
ok( $photo->canEdit(3), "Admin can edit" );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Friends are allowed to view friendsOnly photos
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdEdit => "",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
ok( !$photo->canView(1), "Visitors cannot view" );
|
||||
ok( !$photo->canEdit(1), "Visitors cannot edit" );
|
||||
ok( !$photo->canView(2), "Registered Users cannot view" );
|
||||
ok( !$photo->canEdit(2), "Registered Users cannot edit" );
|
||||
ok( $photo->canView, "Owner can view" );
|
||||
ok( $photo->canEdit, "Owner can edit" );
|
||||
ok( $photo->canView(3), "Admin can view" );
|
||||
ok( $photo->canEdit(3), "Admin can edit" );
|
||||
68
t/Asset/File/Image/Photo/setFile.t
Normal file
68
t/Asset/File/Image/Photo/setFile.t
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 photo assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
imageResolutions => "1024x768",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile also makes download versions
|
||||
$photo->setFile( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
my $storage = $photo->getStorageLocation;
|
||||
|
||||
is_deeply(
|
||||
$storage->getFiles, ['page_title.jpg'],
|
||||
"Storage location contains only the file we added",
|
||||
);
|
||||
|
||||
ok(
|
||||
-e $storage->getPath($gallery->get('imageResolutions') . '.jpg'),
|
||||
"Generated resolution file exists on the filesystem",
|
||||
);
|
||||
|
||||
|
||||
53
t/Asset/File/Image/Photo/view.t
Normal file
53
t/Asset/File/Image/Photo/view.t
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the view and getTemplateVars methods
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->setFile( WebGUI::Test->getCollateralPath('page_title.jpg') );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
62
t/Asset/File/Image/setfile.t
Normal file
62
t/Asset/File/Image/setfile.t
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 additional functionality of the
|
||||
# overridden setFile method
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Image Test"});
|
||||
my $image
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile allows file path argument and adds the file
|
||||
# setFile also generates thumbnail
|
||||
# plan tests => 2
|
||||
$image->setFile( WebGUI::Test->getTestCollateralPath("page_title.jpg") );
|
||||
my $storage = $image->getStorageLocation;
|
||||
|
||||
is_deeply(
|
||||
$storage->getFiles, ['page_title.jpg'],
|
||||
"Storage location contains only the file we added",
|
||||
);
|
||||
|
||||
# We must do a filesystem test because getFiles doesn't include 'thumb-'
|
||||
ok(
|
||||
-e $storage->getPath('thumb-page_title.jpg'),
|
||||
"Thumbnail file exists on the filesystem",
|
||||
);
|
||||
|
||||
63
t/Asset/File/setfile.t
Normal file
63
t/Asset/File/setfile.t
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 photo assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"File Test"});
|
||||
my $file
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile allows file path argument and fails if can't find file
|
||||
# plan tests => 1
|
||||
ok(
|
||||
!eval { $file->setFile( WebGUI::Test->getTestCollateralPath("DOES_NOT_EXIST.NO") ); 1},
|
||||
"setFile allows file path argument and croaks if can't find file"
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile allows file path argument and adds the file
|
||||
# plan tests => 1
|
||||
$file->setFile( WebGUI::Test->getTestCollateralPath("WebGUI.pm") );
|
||||
my $storage = $file->getStorageLocation;
|
||||
|
||||
is_deeply(
|
||||
$storage->getFiles, ['WebGUI.pm'],
|
||||
"Storage location contains only the file we added",
|
||||
);
|
||||
|
||||
|
||||
74
t/Asset/Shortcut/000-create-delete.t
Normal file
74
t/Asset/Shortcut/000-create-delete.t
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 shortcut assets
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::Snippet;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Shortcut Test"});
|
||||
|
||||
# Make a snippet to shortcut
|
||||
my $snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 3;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Shortcut");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating a shortcut to snippet
|
||||
# plan tests => 2
|
||||
my $shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
|
||||
isa_ok(
|
||||
$shortcut, "WebGUI::Asset::Shortcut",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$shortcut, "WebGUI::Asset",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a shortcut
|
||||
# plan tests =>
|
||||
TODO: {
|
||||
local $TODO = "Test deleting a shortcut.";
|
||||
}
|
||||
|
||||
|
||||
126
t/Asset/Shortcut/010-linked-asset.t
Normal file
126
t/Asset/Shortcut/010-linked-asset.t
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 link between the asset and its shortcut
|
||||
# and that changes to the asset are propagated to the shortcut
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::Shortcut;
|
||||
use WebGUI::Asset::Snippet;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Shortcut Test"});
|
||||
|
||||
# Make a snippet to shortcut
|
||||
my $snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
|
||||
my $shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 10;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test shortcut's link to original asset
|
||||
# plan => 3
|
||||
my $original = $shortcut->getShortcut;
|
||||
|
||||
ok(
|
||||
defined $original,
|
||||
"Original asset is defined",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $original, blessed $snippet,
|
||||
"Original asset class is correct",
|
||||
);
|
||||
|
||||
is(
|
||||
$original->getId, $snippet->getId,
|
||||
"Original assetId is correct"
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test trashing snippet trashes shortcut also
|
||||
# plan tests => 3
|
||||
$snippet->trash;
|
||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||
|
||||
ok(
|
||||
defined $shortcut,
|
||||
"Trash Linked Asset: Shortcut is defined",
|
||||
);
|
||||
|
||||
like(
|
||||
$shortcut->get("state"), qr/^trash/,
|
||||
"Trash Linked Asset: Shortcut state is trash",
|
||||
);
|
||||
|
||||
ok(
|
||||
grep({ $_->getId eq $shortcut->getId } @{ $snippet->getAssetsInTrash }),
|
||||
"Trash Linked Asset: Shortcut is in trash",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test restoring snippet restores shortcut also
|
||||
# plan tests => 3
|
||||
$snippet->publish;
|
||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||
|
||||
ok(
|
||||
defined $shortcut,
|
||||
"Restore Linked Asset: Shortcut is defined",
|
||||
);
|
||||
|
||||
ok(
|
||||
!grep({ $_->getId eq $shortcut->getId } @{ $snippet->getAssetsInTrash }),
|
||||
"Restore Linked Asset: Shortcut is not in trash",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test purging snippet purges shortcut also
|
||||
# plan tests => 2
|
||||
$snippet->purge;
|
||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||
|
||||
ok(
|
||||
!defined $shortcut,
|
||||
"Purge Linked Asset: Shortcut is not defined",
|
||||
);
|
||||
|
||||
ok(
|
||||
!grep({ $_->getId eq $shortcut->getId } @{ $snippet->getAssetsInTrash }),
|
||||
"Purge Linked Asset: Shortcut is not in trash",
|
||||
);
|
||||
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;
|
||||
|
||||
78
t/Asset/Wobject/GalleryAlbum/00base.t
Normal file
78
t/Asset/Wobject/GalleryAlbum/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",
|
||||
);
|
||||
|
||||
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
|
|
@ -203,6 +203,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
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Config qw[];
|
|||
use IO::Handle qw[];
|
||||
use File::Spec qw[];
|
||||
use Test::MockObject::Extends;
|
||||
use WebGUI::PseudoRequest;
|
||||
|
||||
##Hack to get ALL test output onto STDOUT.
|
||||
use Test::Builder;
|
||||
|
|
@ -115,6 +116,7 @@ sub config {
|
|||
return $SESSION->config;
|
||||
}
|
||||
|
||||
|
||||
sub file {
|
||||
return $CONFIG_FILE;
|
||||
}
|
||||
|
|
@ -136,7 +138,8 @@ of options with keys outlined below.
|
|||
=cut
|
||||
|
||||
sub getPage {
|
||||
my $session = shift; # The session object
|
||||
my $class = shift;
|
||||
my $session = $SESSION; # The session object
|
||||
my $asset = shift; # The asset object
|
||||
my $page = shift; # The page subroutine
|
||||
my $optionsRef = shift; # A hashref of options
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package WebGUI::Test::Maker::HTML;
|
|||
|
||||
use base 'WebGUI::Test::Maker';
|
||||
use Scalar::Util qw( blessed );
|
||||
use Carp qw( croak );
|
||||
use Test::More;
|
||||
|
||||
|
||||
|
|
@ -72,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
|
||||
|
|
@ -187,7 +190,7 @@ sub prepare {
|
|||
croak("Couldn't prepare: Test $test_num, test_regex is not an array reference")
|
||||
if $test->{test_regex} && ref $test->{test_regex} ne "ARRAY";
|
||||
croak("Couldn't prepare: Test $test_num, $test->{test_privilege} is not a valid test_privilege value (adminOnly, insufficient, noAccess, notMember, vitalComponent)")
|
||||
if $test->{test_privilege} && $test->{test_privilege} =~ m/adminOnly|insufficient|noAccess|notMember|vitalComponent/;
|
||||
if $test->{test_privilege} && $test->{test_privilege} !~ m/adminOnly|insufficient|noAccess|notMember|vitalComponent/;
|
||||
|
||||
push @{$self->{_tests}}, $test;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
BIN
t/supporting_collateral/lamp.jpg
Normal file
BIN
t/supporting_collateral/lamp.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 663 KiB |
Loading…
Add table
Add a link
Reference in a new issue