Added version tag with commits and rollback.
Changed SKIP and TODOs to isolate some more tests. WebGUI::International->get is not a class method.
This commit is contained in:
parent
15c3c2e8f6
commit
b542bf1cfd
1 changed files with 80 additions and 53 deletions
|
|
@ -26,8 +26,11 @@ use WebGUI::Asset::File::Image::Photo;
|
||||||
# Init
|
# Init
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
my $node = WebGUI::Asset->getImportNode($session);
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
|
||||||
$versionTag->set({name=>"Photo Test"});
|
my @versionTags = ();
|
||||||
|
push @versionTags, WebGUI::VersionTag->getWorking($session);
|
||||||
|
$versionTags[-1]->set({name=>"Photo Test, add Gallery, Album and 1 Photo"});
|
||||||
|
|
||||||
my $gallery
|
my $gallery
|
||||||
= $node->addChild({
|
= $node->addChild({
|
||||||
className => "WebGUI::Asset::Wobject::Gallery",
|
className => "WebGUI::Asset::Wobject::Gallery",
|
||||||
|
|
@ -36,24 +39,27 @@ my $gallery
|
||||||
my $album
|
my $album
|
||||||
= $gallery->addChild({
|
= $gallery->addChild({
|
||||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||||
|
},
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
{
|
||||||
|
skipAutoCommitWorkflows => 1,
|
||||||
});
|
});
|
||||||
my $photo
|
my $photo
|
||||||
= $album->addChild({
|
= $album->addChild({
|
||||||
className => "WebGUI::Asset::File::Image::Photo",
|
className => "WebGUI::Asset::File::Image::Photo",
|
||||||
|
},
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
{
|
||||||
|
skipAutoCommitWorkflows => 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
$versionTags[-1]->commit;
|
||||||
# Cleanup
|
|
||||||
END {
|
|
||||||
$photo->purge;
|
|
||||||
$album->purge;
|
|
||||||
$gallery->purge;
|
|
||||||
$versionTag->rollback();
|
|
||||||
};
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
plan tests => 28;
|
plan tests => 29;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test with no comments
|
# Test with no comments
|
||||||
|
|
@ -192,67 +198,88 @@ ok(
|
||||||
# Test appendTemplateVarsForCommentForm
|
# Test appendTemplateVarsForCommentForm
|
||||||
TODO: {
|
TODO: {
|
||||||
local $TODO = "Test appendTemplateVarsForCommentForm";
|
local $TODO = "Test appendTemplateVarsForCommentForm";
|
||||||
|
ok(0, "Test template variable generation");
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test www_addCommentSave page sanity checks
|
# Test www_addCommentSave page sanity checks
|
||||||
my $html;
|
my $html;
|
||||||
SKIP: {
|
$photo
|
||||||
skip "getParent isn't working in tests, so these tests fail...", 2;
|
= $album->addChild({
|
||||||
$photo
|
className => "WebGUI::Asset::File::Image::Photo",
|
||||||
= $album->addChild({
|
},
|
||||||
className => "WebGUI::Asset::File::Image::Photo",
|
undef,
|
||||||
});
|
undef,
|
||||||
|
{
|
||||||
|
skipAutoCommitWorkflows => 1,
|
||||||
|
});
|
||||||
|
|
||||||
# Permissions
|
# Permissions
|
||||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||||
userId => 1,
|
userId => 1,
|
||||||
formParams => { bodyText => "yes?" },
|
formParams => { bodyText => "yes?" },
|
||||||
});
|
});
|
||||||
|
|
||||||
like(
|
like(
|
||||||
$html, qr/permission denied/i,
|
$html, qr/permission denied/i,
|
||||||
"www_addCommentSave -- Permission denied if not Gallery->canAddComment",
|
"www_addCommentSave -- Permission denied if not Gallery->canAddComment",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $i18n = $photo->i18n($session);
|
||||||
|
|
||||||
|
SKIP: {
|
||||||
|
skip "www_addCommentSave needs to check for bodyText", 1;
|
||||||
|
|
||||||
# Required fields
|
# Required fields
|
||||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||||
userId => 2,
|
userId => 1,
|
||||||
formParams => { },
|
formParams => { },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
like(
|
||||||
|
$html, $i18n->get("www_addCommentSave error missing required"),
|
||||||
|
"www_addCommentSave -- Must have bodyText defined",
|
||||||
|
);
|
||||||
|
|
||||||
like(
|
|
||||||
$html, WebGUI::International->get($session, "Asset_Photo", "www_addCommentSave error missing required"),
|
|
||||||
"www_addCommentSave -- Must have bodyText defined",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test www_addCommentSave functionality
|
# Test www_addCommentSave functionality
|
||||||
SKIP: {
|
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||||
skip "getParent isn't working in tests, so these tests fail...", 4;
|
userId => 1,
|
||||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
formParams => { bodyText => "YES!", },
|
||||||
userId => 2,
|
});
|
||||||
formParams => { bodyText => "YES!", },
|
|
||||||
});
|
|
||||||
|
|
||||||
like(
|
like(
|
||||||
$html, WebGUI::International->get($session, "Asset_Photo", "www_addCommentSave success"),
|
$html, $i18n->get("www_addCommentSave success"),
|
||||||
"www_addCommentSave -- page shows success message",
|
"www_addCommentSave -- page shows success message",
|
||||||
);
|
);
|
||||||
|
|
||||||
my $ids = $photo->getCommentIds;
|
my $ids = $photo->getCommentIds;
|
||||||
is(
|
is(
|
||||||
scalar @$ids, 1,
|
scalar @$ids, 1,
|
||||||
"www_addCommentSave -- Comment was added",
|
"www_addCommentSave -- Comment was added",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
is(
|
is(
|
||||||
$photo->getComment( $ids->[0] )->{visitorIp}, undef,
|
$photo->getComment( $ids->[0] )->{visitorIp}, undef,
|
||||||
"Non-visitor does not have their IP logged"
|
"Non-visitor does not have their IP logged"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
TODO: {
|
||||||
|
local $TODO = "Not programmed yet";
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
ok( 0, "Visitor has their IP logged in visitorIp field" );
|
ok( 0, "Visitor has their IP logged in visitorIp field" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Cleanup
|
||||||
|
END {
|
||||||
|
foreach my $versionTag (@versionTags) {
|
||||||
|
$versionTag->rollback;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue