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:
parent
9e4216c4a0
commit
a548341aea
2 changed files with 10 additions and 6 deletions
|
|
@ -674,8 +674,8 @@ sub setParent {
|
||||||
$self->updateHistory("moved to parent ".$newParent->getId);
|
$self->updateHistory("moved to parent ".$newParent->getId);
|
||||||
$self->{_properties}{lineage} = $lineage;
|
$self->{_properties}{lineage} = $lineage;
|
||||||
$self->purgeCache;
|
$self->purgeCache;
|
||||||
|
$self->{_parent} = $newParent;
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
|
||||||
use WebGUI::Asset;
|
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;
|
use Test::Deep;
|
||||||
|
|
||||||
# Test the methods in WebGUI::AssetLineage
|
# Test the methods in WebGUI::AssetLineage
|
||||||
|
|
@ -126,12 +126,16 @@ 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(), 'setParent: new parent must be passed in');
|
||||||
ok(!$snippet2->setParent($snippet2), 'setParent: cannot be your own parent');
|
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($folder2), 'setParent: will not move self to current parent');
|
||||||
ok(!$snippet2->setParent($folder), 'setParent: user must be in group 4 to do this');
|
ok(!$folder2->setParent($snippet2), 'setParent: will not move self to my child');
|
||||||
$session->user({userId => 3});
|
|
||||||
ok($snippet2->setParent($folder), 'setParent: Admin can run setParent');
|
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');
|
is($folder->getChildCount, 8, 'setParent: folder now has 8 children');
|
||||||
|
|
||||||
END {
|
END {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue