More AssetLineage tests.

setParent does not clear the internally cached reference to
the parent Asset.  This makes persistent code get the wrong
Asset reference.
This commit is contained in:
Colin Kuskie 2007-04-13 21:01:15 +00:00
parent 9e4216c4a0
commit a548341aea
2 changed files with 10 additions and 6 deletions

View file

@ -674,8 +674,8 @@ sub setParent {
$self->updateHistory("moved to parent ".$newParent->getId);
$self->{_properties}{lineage} = $lineage;
$self->purgeCache;
$self->{_parent} = $newParent;
return 1;
return 0;
}
#-------------------------------------------------------------------

View file

@ -16,7 +16,7 @@ use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Asset;
use Test::More tests => 15; # increment this value for each test you create
use Test::More tests => 17; # increment this value for each test you create
use Test::Deep;
# Test the methods in WebGUI::AssetLineage
@ -126,13 +126,17 @@ ok(!$snippets[0]->hasChildren, 'test snippet has no children');
#
####################################################
ok(!$snippet2->setParent($folder), 'setParent: user must be in group 4 to do this');
$session->user({userId => 3});
ok(!$snippet2->setParent(), 'setParent: new parent must be passed in');
ok(!$snippet2->setParent($snippet2), 'setParent: cannot be your own parent');
ok(!$snippet2->setParent($folder2), 'setParent: will not move self to current parent');
ok(!$snippet2->setParent($folder), 'setParent: user must be in group 4 to do this');
$session->user({userId => 3});
ok($snippet2->setParent($folder), 'setParent: Admin can run setParent');
is($folder->getChildCount, 8, 'setParent: folder now has 8 children');
ok(!$folder2->setParent($snippet2), 'setParent: will not move self to my child');
ok($snippet2->setParent($folder), 'setParent: successfully set');
is($snippet2->getParent->getId, $folder->getId, 'setParent successfully set parent');
is($folder->getChildCount, 8, 'setParent: folder now has 8 children');
END {
$versionTag->rollback;