add more tests to cover AssetLineage->getChildCount. Optimize the new SQL query in getChildCount
This commit is contained in:
parent
0799d70428
commit
80333b1141
2 changed files with 12 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue