From 8d65d4322ccb662086c26f5d397eb2a01ae5c0f5 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 15 Apr 2007 05:00:06 +0000 Subject: [PATCH] getLineage tests. This thing is so big it could have its own test file. --- t/Asset/AssetLineage.t | 48 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/t/Asset/AssetLineage.t b/t/Asset/AssetLineage.t index 55caabd20..7a64f5d1d 100644 --- a/t/Asset/AssetLineage.t +++ b/t/Asset/AssetLineage.t @@ -17,7 +17,7 @@ use WebGUI::Session; use WebGUI::User; use WebGUI::Asset; -use Test::More tests => 67; # increment this value for each test you create +use Test::More tests => 72; # increment this value for each test you create use Test::Deep; # Test the methods in WebGUI::AssetLineage @@ -352,6 +352,7 @@ ok($folder->hasChildren, 'hasChildren: cached from getFirstChild'); # newByLineage # #################################################### + ##Clear the stowed assetLineage hash $session->stow->delete('assetLineage'); my $snippet4 = WebGUI::Asset->newByLineage($session, $snippets[4]->get('lineage')); @@ -369,6 +370,51 @@ delete $cachedLineage->{$snippet4->get('lineage')}->{class}; my $snippet4 = WebGUI::Asset->newByLineage($session, $snippets[4]->get('lineage')); is ($snippet4->getId, $snippets[4]->getId, 'newByLineage: failing class cache forces lookup'); +#################################################### +# +# getLineage +# +#################################################### + +@snipIds = map { $_->getId } @snippets; +my $ids = $folder->getLineage(['descendants']); +cmp_bag( + \@snipIds, + $ids, + 'getLineage: get descendants of folder' +); + +$ids = $folder->getLineage(['self','descendants']); +unshift @snipIds, $folder->getId; +cmp_bag( + \@snipIds, + $ids, + 'getLineage: get descendants of folder and self' +); + +$ids = $folder->getLineage(['self','children']); +cmp_bag( + \@snipIds, + $ids, + 'getLineage: descendants == children if there are no grandchildren' +); + +$ids = $topFolder->getLineage(['self','children']); +cmp_bag( + [$topFolder->getId, $folder->getId, $folder2->getId, ], + $ids, + 'getLineage: children (no descendants) of topFolder', +); + +$ids = $topFolder->getLineage(['self','descendants']); +cmp_bag( + [$topFolder->getId, @snipIds, $folder2->getId, $snippet2->getId], + $ids, + 'getLineage: descendants of topFolder', +); + + + END { $versionTag->rollback; foreach my $account ($editor) {