From 7be4f8ea82d69e867d4fded7ec3629db575c9047 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 21 Dec 2007 21:47:15 +0000 Subject: [PATCH] Remove all tests with no internal tests, or that are exact copies of GalleryAlbum tests. Update 00base.t to test the Gallery instead of the GalleryAlbum. --- t/Asset/Wobject/Gallery/00base.t | 52 ++++----- t/Asset/Wobject/Gallery/delete.t | 96 --------------- t/Asset/Wobject/Gallery/listFilesForUser.t | 78 ------------- t/Asset/Wobject/Gallery/permission.t | 107 ----------------- t/Asset/Wobject/Gallery/rss.t | 66 ----------- t/Asset/Wobject/Gallery/search.t | 78 ------------- t/Asset/Wobject/Gallery/view.t | 130 --------------------- 7 files changed, 21 insertions(+), 586 deletions(-) delete mode 100644 t/Asset/Wobject/Gallery/delete.t delete mode 100644 t/Asset/Wobject/Gallery/listFilesForUser.t delete mode 100644 t/Asset/Wobject/Gallery/permission.t delete mode 100644 t/Asset/Wobject/Gallery/rss.t delete mode 100644 t/Asset/Wobject/Gallery/search.t delete mode 100644 t/Asset/Wobject/Gallery/view.t diff --git a/t/Asset/Wobject/Gallery/00base.t b/t/Asset/Wobject/Gallery/00base.t index d6d4c2286..d214e5570 100644 --- a/t/Asset/Wobject/Gallery/00base.t +++ b/t/Asset/Wobject/Gallery/00base.t @@ -25,54 +25,44 @@ my $session = WebGUI::Test->session; my $node = WebGUI::Asset->getImportNode($session); my $versionTag = WebGUI::VersionTag->getWorking($session); $versionTag->set({name=>"Album Test"}); + +#---------------------------------------------------------------------------- +# Tests +plan tests => 4; + +#---------------------------------------------------------------------------- +# Test module compiles okay +use_ok("WebGUI::Asset::Wobject::Gallery"); + 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", - }); +$versionTag->commit; is( - blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum", - "Album is a WebGUI::Asset::Wobject::GalleryAlbum object", + blessed $gallery, "WebGUI::Asset::Wobject::Gallery", + "Gallery is a WebGUI::Asset::Wobject::Gallery object", ); isa_ok( - $album, "WebGUI::Asset::Wobject", + $gallery, "WebGUI::Asset::Wobject", ); #---------------------------------------------------------------------------- # Test deleting a album -my $properties = $album->get; -$album->purge; - -is( - $album, undef, - "Album is undefined", -); +my $properties = $gallery->get; +$gallery->purge; is( WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef, "Album no longer able to be instanciated", ); + +#---------------------------------------------------------------------------- +# Cleanup +END { + $versionTag->rollback(); +} diff --git a/t/Asset/Wobject/Gallery/delete.t b/t/Asset/Wobject/Gallery/delete.t deleted file mode 100644 index 1704ec0c0..000000000 --- a/t/Asset/Wobject/Gallery/delete.t +++ /dev/null @@ -1,96 +0,0 @@ -# $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", -); - diff --git a/t/Asset/Wobject/Gallery/listFilesForUser.t b/t/Asset/Wobject/Gallery/listFilesForUser.t deleted file mode 100644 index d6d4c2286..000000000 --- a/t/Asset/Wobject/Gallery/listFilesForUser.t +++ /dev/null @@ -1,78 +0,0 @@ -#------------------------------------------------------------------- -# 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", -); - diff --git a/t/Asset/Wobject/Gallery/permission.t b/t/Asset/Wobject/Gallery/permission.t deleted file mode 100644 index d8d8c0596..000000000 --- a/t/Asset/Wobject/Gallery/permission.t +++ /dev/null @@ -1,107 +0,0 @@ -#------------------------------------------------------------------- -# 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; - diff --git a/t/Asset/Wobject/Gallery/rss.t b/t/Asset/Wobject/Gallery/rss.t deleted file mode 100644 index 7a73e5d6b..000000000 --- a/t/Asset/Wobject/Gallery/rss.t +++ /dev/null @@ -1,66 +0,0 @@ -# $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 - diff --git a/t/Asset/Wobject/Gallery/search.t b/t/Asset/Wobject/Gallery/search.t deleted file mode 100644 index d6d4c2286..000000000 --- a/t/Asset/Wobject/Gallery/search.t +++ /dev/null @@ -1,78 +0,0 @@ -#------------------------------------------------------------------- -# 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", -); - diff --git a/t/Asset/Wobject/Gallery/view.t b/t/Asset/Wobject/Gallery/view.t deleted file mode 100644 index dedd4f74a..000000000 --- a/t/Asset/Wobject/Gallery/view.t +++ /dev/null @@ -1,130 +0,0 @@ -# $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; -