More rank swapping tests, cleaned up a bug in the tests that passed but should
not have. Updated the POD in AssetLineage to show which methods alter the object's stored lineage versus the information in the database.
This commit is contained in:
parent
5e643336bb
commit
483daf6671
2 changed files with 30 additions and 6 deletions
|
|
@ -17,7 +17,7 @@ use WebGUI::Session;
|
|||
use WebGUI::User;
|
||||
|
||||
use WebGUI::Asset;
|
||||
use Test::More tests => 45; # increment this value for each test you create
|
||||
use Test::More tests => 49; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
# Test the methods in WebGUI::AssetLineage
|
||||
|
|
@ -60,6 +60,7 @@ foreach my $snipNum (0..6) {
|
|||
groupIdEdit => 3,
|
||||
title => "Snippet $snipNum",
|
||||
menuTitle => $snipNum,
|
||||
url => 'snippet'.$snipNum,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +101,8 @@ is($snippets[-1]->getId, $folder->getLastChild->getId, 'getLastChild');
|
|||
#
|
||||
####################################################
|
||||
|
||||
is(scalar @snippets, $folder->getChildCount, 'getChildCount');
|
||||
is(scalar @snippets, $folder->getChildCount, 'getChildCount on folder with several children');
|
||||
is(1, $folder2->getChildCount, 'getChildCount on folder with 1 child');
|
||||
|
||||
####################################################
|
||||
#
|
||||
|
|
@ -209,12 +211,15 @@ cmp_bag(
|
|||
'swapRank: swapped first and second snippets'
|
||||
);
|
||||
|
||||
@snippets[0..1] = map { WebGUI::Asset->newByUrl($session, "snippet$_") } 0..1;
|
||||
|
||||
is(
|
||||
$snippets[3]->swapRank($snippets[0]->get('lineage'), $snippets[0]->get('lineage'), ),
|
||||
$snippets[1]->swapRank($snippets[0]->get('lineage'), $snippets[1]->get('lineage'), ),
|
||||
1,
|
||||
'swapRank: remote, two different snippets to restore original order'
|
||||
);
|
||||
|
||||
@snippets[0..1] = map { WebGUI::Asset->newByUrl($session, "snippet$_") } 0..1;
|
||||
@snipIds[0,1] = @snipIds[1,0];
|
||||
$lineageIds = $folder->getLineage(['descendants']);
|
||||
cmp_bag(
|
||||
|
|
@ -223,6 +228,18 @@ cmp_bag(
|
|||
'swapRank: swapped first and second snippets'
|
||||
);
|
||||
|
||||
|
||||
ok($folder->swapRank($folder2->get('lineage')), 'swap folder and folder2');
|
||||
|
||||
is(scalar @snippets, $folder->getChildCount, 'changing lineage does not change relationship in folder');
|
||||
is(1 , $folder2->getChildCount, 'changing lineage does not change relationship in folder2');
|
||||
|
||||
##Reinstance the asset object due to db manipulation
|
||||
$folder = WebGUI::Asset->newByUrl($session, $folder->get('url'));
|
||||
$folder2 = WebGUI::Asset->newByUrl($session, $folder2->get('url'));
|
||||
@snippets = map { WebGUI::Asset->newByUrl($session, "snippet$_") } 0..6;
|
||||
$snippet2 = WebGUI::Asset->newByUrl($session, $snippet2->get('url'));
|
||||
|
||||
####################################################
|
||||
#
|
||||
# demote
|
||||
|
|
@ -252,6 +269,7 @@ cmp_bag(
|
|||
#
|
||||
####################################################
|
||||
|
||||
|
||||
ok(!$snippets[0]->promote(), 'promote: first snippet in the set will not swap');
|
||||
$lineageIds = $folder->getLineage(['descendants']);
|
||||
cmp_bag(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue