Tests for getParent and getParentLineage
Fixed getParentLineage. The regular expression only matched strings that were 8 characters long.
This commit is contained in:
parent
a548341aea
commit
e894ed29ae
2 changed files with 27 additions and 2 deletions
|
|
@ -540,7 +540,9 @@ Optional lineage of another Asset.
|
||||||
sub getParentLineage {
|
sub getParentLineage {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $lineage = shift || $self->get("lineage");
|
my $lineage = shift || $self->get("lineage");
|
||||||
my ($parentLineage) = $lineage =~ m/^(.).{6}$/;
|
my $lineageLength = length($lineage) - 6;
|
||||||
|
return $lineage unless $lineageLength;
|
||||||
|
my $parentLineage = substr($lineage, 0, $lineageLength);
|
||||||
return $parentLineage;
|
return $parentLineage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
|
||||||
use WebGUI::Asset;
|
use WebGUI::Asset;
|
||||||
use Test::More tests => 17; # increment this value for each test you create
|
use Test::More tests => 22; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
|
|
||||||
# Test the methods in WebGUI::AssetLineage
|
# Test the methods in WebGUI::AssetLineage
|
||||||
|
|
@ -97,6 +97,29 @@ is($snippets[-1]->getId, $folder->getLastChild->getId, 'getLastChild');
|
||||||
|
|
||||||
is(scalar @snippets, $folder->getChildCount, 'getChildCount');
|
is(scalar @snippets, $folder->getChildCount, 'getChildCount');
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
#
|
||||||
|
# getParent
|
||||||
|
#
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
is($snippets[0]->getParent->getId, $folder->getId, 'getParent');
|
||||||
|
is($root->getParent->getId, $root->getId, "getParent: root's parent is itself");
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
#
|
||||||
|
# getParentLineage
|
||||||
|
#
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
is($snippets[0]->getParentLineage, $folder->get('lineage'), 'getParentLineage: self');
|
||||||
|
is($root->getParentLineage, '000001', 'getParentLineage: root');
|
||||||
|
is(
|
||||||
|
$root->getParentLineage('000001000002'),
|
||||||
|
'000001',
|
||||||
|
'getParentLineage: arbitrary lineage'
|
||||||
|
);
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
#
|
#
|
||||||
# hasChildren
|
# hasChildren
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue