diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index e7a017125..e689502a2 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -187,7 +187,7 @@ sub getChildCount { my $self = shift; my $opts = shift || {}; my $stateWhere = $opts->{includeTrash} ? '' : "asset.state='published' and"; - my ($count) = $self->session->db->quickArray("select count(asset.state) from asset, assetData where asset.assetId=assetData.assetId and $stateWhere parentId=? and assetData.status in ('approved', 'archived')", [$self->getId]); + my ($count) = $self->session->db->quickArray("select count(*) from asset, assetData where asset.assetId=assetData.assetId and $stateWhere parentId=? and assetData.status in ('approved', 'archived')", [$self->getId]); return $count; } diff --git a/t/Asset/AssetLineage.t b/t/Asset/AssetLineage.t index c5e408fdc..06b36d2e7 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 => 78; # increment this value for each test you create +use Test::More tests => 82; # increment this value for each test you create use Test::Deep; # Test the methods in WebGUI::AssetLineage @@ -119,6 +119,16 @@ $folder->update({status => 'pending'}); is(1, $topFolder->getChildCount, 'getChildCount with one child pending'); $folder->update({status => 'approved'}); +$folder2->trash(); +is(1, $topFolder->getChildCount, 'getChildCount with one child trashed'); +is(2, $topFolder->getChildCount({includeTrash => 1}), 'getChildCount with one child trash but includeTrash = 1'); +$folder2->publish(); + +$folder2->cut(); +is(1, $topFolder->getChildCount, 'getChildCount with one child in the clipboard'); +$folder2->publish(); +is(2, $topFolder->getChildCount, 'getChildCount: restored original setup for next series of tests'); + #################################################### # # getDescendantCount