Change this test to use a Snippet instead of a Template.
This commit is contained in:
parent
d66b3b891b
commit
e940dc0427
1 changed files with 32 additions and 32 deletions
|
|
@ -18,19 +18,19 @@ use lib "$FindBin::Bin/../lib";
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::Asset::Snippet;
|
||||
use Test::More; # increment this value for each test you create
|
||||
plan tests => 26;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $propertyHash = {
|
||||
template => "Hi, I'm a template",
|
||||
template => "Hi, I'm a snippet",
|
||||
url => '/template/versionTest',
|
||||
title => 'Version Test Template',
|
||||
menuTitle => 'Version Test Template',
|
||||
namespace => 'Article',
|
||||
className => 'WebGUI::Asset::Template',
|
||||
title => 'Version Test Snippet',
|
||||
menuTitle => 'Version Test Snippet',
|
||||
namespace => 'Snippet',
|
||||
className => 'WebGUI::Asset::Snippet',
|
||||
};
|
||||
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
|
@ -44,35 +44,35 @@ my $originalVersionTags = $session->db->quickScalar(q{select count(*) from asset
|
|||
################################################################
|
||||
|
||||
note "purgeRevision tests";
|
||||
my $template = $root->addChild($propertyHash);
|
||||
$template->commit;
|
||||
my $snippet = $root->addChild($propertyHash);
|
||||
$snippet->commit;
|
||||
|
||||
is (ref $template, "WebGUI::Asset::Template", "Template Asset created");
|
||||
checkTableEntries($template->getId, 1,1,1,1);
|
||||
isa_ok $snippet, "WebGUI::Asset::Snippet";
|
||||
checkTableEntries($snippet->getId, 1,1,1,1);
|
||||
|
||||
sleep 1;
|
||||
|
||||
my $templatev2 = $template->addRevision({template => 'Hello, I am a template with formal grammar'});
|
||||
$templatev2->commit;
|
||||
my $snippetv2 = $snippet->addRevision({snippet => 'Hello, I am a snippet with formal grammar'});
|
||||
$snippetv2->commit;
|
||||
|
||||
is ($templatev2->getId, $template->getId, 'Both versions of the asset have the same assetId');
|
||||
checkTableEntries($templatev2->getId, 1,2,2,1);
|
||||
is ($snippetv2->getId, $snippet->getId, 'Both versions of the asset have the same assetId');
|
||||
checkTableEntries($snippetv2->getId, 1,2,2,1);
|
||||
|
||||
$templatev2->purgeRevision;
|
||||
$snippetv2->purgeRevision;
|
||||
|
||||
checkTableEntries($templatev2->getId, 1,1,1,1);
|
||||
checkTableEntries($snippetv2->getId, 1,1,1,1);
|
||||
|
||||
undef $templatev2;
|
||||
undef $snippetv2;
|
||||
|
||||
my $templatev2a = $template->addRevision({template => 'Hey, yall! Ima template.'});
|
||||
$templatev2a->commit;
|
||||
my $snippetv2a = $snippet->addRevision({snippet => 'Hey, yall! Ima snippet.'});
|
||||
$snippetv2a->commit;
|
||||
|
||||
$template->purgeRevision;
|
||||
$snippet->purgeRevision;
|
||||
|
||||
checkTableEntries($template->getId, 1,1,1,1);
|
||||
checkTableEntries($snippet->getId, 1,1,1,1);
|
||||
|
||||
$template->purgeRevision;
|
||||
checkTableEntries($template->getId, 0,0,0,0);
|
||||
$snippet->purgeRevision;
|
||||
checkTableEntries($snippet->getId, 0,0,0,0);
|
||||
|
||||
my $versionTagCheck;
|
||||
$versionTagCheck = $session->db->quickScalar(q{select count(*) from assetVersionTag});
|
||||
|
|
@ -84,22 +84,22 @@ is($versionTagCheck, $originalVersionTags, 'version tag cleaned up by deleting l
|
|||
#
|
||||
################################################################
|
||||
|
||||
$template = $root->addChild($propertyHash);
|
||||
$snippet = $root->addChild($propertyHash);
|
||||
my $tag1 = WebGUI::VersionTag->getWorking($session);
|
||||
$tag1->commit;
|
||||
WebGUI::Test->tagsToRollback($tag1);
|
||||
sleep 1;
|
||||
$templatev2 = $template->addRevision({template => 'Vie gates. Ich bin ein templater.'});
|
||||
$snippetv2 = $snippet->addRevision({snippet => 'Vie gates. Ich bin ein snippetr.'});
|
||||
my $tag2 = WebGUI::VersionTag->getWorking($session);
|
||||
$tag2->commit;
|
||||
WebGUI::Test->tagsToRollback($tag2);
|
||||
note "purge";
|
||||
checkTableEntries($templatev2->getId, 1,2,2);
|
||||
checkTableEntries($snippetv2->getId, 1,2,2);
|
||||
$versionTagCheck = $session->db->quickScalar(q{select count(*) from assetVersionTag});
|
||||
is($versionTagCheck, $originalVersionTags+2, 'created two version tags');
|
||||
|
||||
$template->purge;
|
||||
checkTableEntries($templatev2->getId, 0,0,0);
|
||||
$snippet->purge;
|
||||
checkTableEntries($snippetv2->getId, 0,0,0);
|
||||
$versionTagCheck = $session->db->quickScalar(q{select count(*) from assetVersionTag});
|
||||
is($versionTagCheck, $originalVersionTags, 'purge deleted both tags');
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ is($versionTagCheck, $originalVersionTags, 'purge deleted both tags');
|
|||
################################################################
|
||||
|
||||
sub checkTableEntries {
|
||||
my ($assetId, $assetNum, $assetDataNum, $templateNum) = @_;
|
||||
my ($assetId, $assetNum, $assetDataNum, $snippetNum) = @_;
|
||||
my ($count) = $session->db->quickArray('select COUNT(*) from asset where assetId=?', [$assetId]);
|
||||
is ($count, $assetNum,
|
||||
sprintf 'Expecting %d Assets with that id in asset', $assetNum);
|
||||
|
|
@ -119,7 +119,7 @@ sub checkTableEntries {
|
|||
is ($count, $assetDataNum,
|
||||
sprintf 'Expecting %d Assets with that id in assetData', $assetDataNum);
|
||||
|
||||
($count) = $session->db->quickArray('select COUNT(*) from template where assetId=?', [$assetId]);
|
||||
is ($count, $templateNum,
|
||||
sprintf 'Expecting %d Assets with that id in template', $templateNum);
|
||||
($count) = $session->db->quickArray('select COUNT(*) from snippet where assetId=?', [$assetId]);
|
||||
is ($count, $snippetNum,
|
||||
sprintf 'Expecting %d Assets with that id in snippet', $snippetNum);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue