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.
This commit is contained in:
Colin Kuskie 2007-12-21 21:47:15 +00:00
parent 4a95c73cc8
commit 7be4f8ea82
7 changed files with 21 additions and 586 deletions

View file

@ -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();
}

View file

@ -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",
);

View file

@ -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",
);

View file

@ -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;

View file

@ -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

View file

@ -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",
);

View file

@ -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;