more tests, started Photo development, changed some naming

This commit is contained in:
Doug Bell 2007-10-25 06:20:20 +00:00
parent 320c2c07b0
commit 32b27d0954
14 changed files with 1261 additions and 150 deletions

View file

@ -25,6 +25,15 @@ 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
@ -44,50 +53,6 @@ use_ok("WebGUI::Asset::File::Image::Photo");
#----------------------------------------------------------------------------
# Test creating a photo
my $photo
= $node->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(
$photo->getGallery, undef,
"Photo->getGallery returns undef if photo not part of a Photo Gallery",
);
#----------------------------------------------------------------------------
# Test deleting a photo
my $properties = $photo->get;
$photo->purge;
is(
$photo, undef
"Photo is undefined",
);
is(
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
"Photo no longer able to be instanciated",
);
#----------------------------------------------------------------------------
# Test creating a photo as part of a photo album
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::PhotoGallery",
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::PhotoAlbum",
});
$photo
= $album->addChild({
className => "WebGUI::Asset::File::Image::Photo",
});
@ -102,6 +67,17 @@ isa_ok(
);
is(
blessed $photo->getGallery, "WebGUI::Asset::Wobject::PhotoGallery",
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",
);

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

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

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

View file

@ -8,8 +8,8 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
# The goal of this test is to test the editSave and
# processPropertiesFromFormPost methods.
# The goal of this test is to test the editSave,
# processPropertiesFromFormPost, and applyConstraints methods.
use FindBin;
use strict;
@ -28,14 +28,15 @@ 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::PhotoGallery",
className => "WebGUI::Asset::Wobject::Gallery",
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::PhotoAlbum",
className => "WebGUI::Asset::Wobject::GalleryAlbum",
});
my $photo
= $gallery->addChild({
@ -50,7 +51,7 @@ END {
#----------------------------------------------------------------------------
# Tests
plan tests => 0;
plan no_plan => 1;
#----------------------------------------------------------------------------
# Test permissions
@ -76,11 +77,11 @@ $maker->prepare({
# TODO: This test should use i18n.
# TODO: This error / test should occur in File, not Photo
$maker->prepare({
object => $album
object => $album,
method => "www_editSave",
formParams => {
assetId => "new",
className => "WebGUI::Asset::File::Image::Photo",
},
test_regex => [
qr/You must select a file/,
@ -90,5 +91,17 @@ $maker->prepare({
#----------------------------------------------------------------------------
# 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;
#----------------------------------------------------------------------------

View file

@ -26,6 +26,22 @@ my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Photo Test"});
my ($photo);
$session->user({ userId => 3 });
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
@ -35,14 +51,14 @@ END {
#----------------------------------------------------------------------------
# Tests
plan tests => 0;
plan no_plan => 1;
#----------------------------------------------------------------------------
# Photo assets outside of Gallery assets
# Everyone can view, Admins can edit, Owned by current user
$photo
= $node->addChild({
= $album->addChild({
className => "WebGUI::Asset::File::Image::Photo",
groupIdView => "7",
groupIdEdit => "3",
@ -58,9 +74,9 @@ 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( WebGUI::User->new($session, "1") );
$session->user( { user => WebGUI::User->new($session, "1") } );
$photo
= $node->addChild({
= $album->addChild({
className => "WebGUI::Asset::File::Image::Photo",
groupIdView => "3",
groupIdEdit => "3",
@ -73,24 +89,7 @@ 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($oldUser);
#----------------------------------------------------------------------------
# Photo assets inside of Gallery assets
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::PhotoGallery",
groupIdView => "7",
groupIdEdit => "3",
ownerUserId => $session->user->userId,
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::PhotoAlbum",
groupIdView => "",
groupIdEdit => "",
ownerUserId => $session->user->userId,
});
$session->user( { user => $oldUser } );
# Photo without specific view/edit inherits from gallery properties
$photo

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

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