State and status fix for AssetLineage->getDescendantCount, and tests to
double check it.
This commit is contained in:
parent
80333b1141
commit
185a582ef9
2 changed files with 11 additions and 6 deletions
|
|
@ -195,13 +195,14 @@ sub getChildCount {
|
|||
|
||||
=head2 getDescendantCount ( )
|
||||
|
||||
Returns the number of descendants this asset has. This excludes assets in the trash or clipboard.
|
||||
Returns the number of descendants this asset has. This includes only assets that are published, and not
|
||||
in the clipboard or trash.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDescendantCount {
|
||||
my $self = shift;
|
||||
my ($count) = $self->session->db->quickArray("select count(*) from asset where state in ('published', 'archived') and lineage like ?", [$self->get("lineage")."%"]);
|
||||
my ($count) = $self->session->db->quickArray("select count(*) from asset, assetData where asset.assetId=assetData.assetId and asset.state = 'published' and assetData.status in ('approved','archived') and asset.lineage like ?", [$self->get("lineage")."%"]);
|
||||
$count--; # have to subtract self
|
||||
return $count;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use WebGUI::Session;
|
|||
use WebGUI::User;
|
||||
|
||||
use WebGUI::Asset;
|
||||
use Test::More tests => 82; # increment this value for each test you create
|
||||
use Test::More tests => 83; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
# Test the methods in WebGUI::AssetLineage
|
||||
|
|
@ -135,9 +135,13 @@ is(2, $topFolder->getChildCount, 'getChildCount: restored original setup for nex
|
|||
#
|
||||
####################################################
|
||||
|
||||
is(10, $topFolder->getDescendantCount, 'getDescendantCount on top folder');
|
||||
is(scalar @snippets, $folder->getDescendantCount, 'getDescendantCount on folder with several children');
|
||||
is(1, $folder2->getDescendantCount, 'getDescendantCount on folder with 1 child');
|
||||
is($topFolder->getDescendantCount, 10, 'getDescendantCount on top folder');
|
||||
is($folder->getDescendantCount, scalar @snippets, 'getDescendantCount on folder with several children');
|
||||
is($folder2->getDescendantCount, 1, 'getDescendantCount on folder with 1 child');
|
||||
|
||||
$folder->update({status => 'pending'});
|
||||
is($topFolder->getDescendantCount, 9, 'getDescendantCount with one child pending');
|
||||
$folder->update({status => 'approved'});
|
||||
|
||||
####################################################
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue