Test adding children, along with automatically adding folders.
This commit is contained in:
parent
02dc71055b
commit
bd59ac6006
2 changed files with 16 additions and 3 deletions
|
|
@ -34,8 +34,11 @@ sub addChild {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($properties) = @_;
|
my ($properties) = @_;
|
||||||
##Allow subclassing
|
##Allow subclassing
|
||||||
return undef unless $properties->{className} =~ /^WebGUI::Asset::Story::/;
|
return undef unless $properties->{className} =~ /^WebGUI::Asset::Story/;
|
||||||
return $self->SUPER::addChild(@_);
|
my $todayFolder = $self->getFolder;
|
||||||
|
return undef unless $todayFolder;
|
||||||
|
my $story = $todayFolder->addChild(@_);
|
||||||
|
return $story;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ $canPostMaker->prepare({
|
||||||
});
|
});
|
||||||
|
|
||||||
my $tests = 1;
|
my $tests = 1;
|
||||||
plan tests => 13
|
plan tests => 19
|
||||||
+ $tests
|
+ $tests
|
||||||
+ $canPostMaker->plan
|
+ $canPostMaker->plan
|
||||||
;
|
;
|
||||||
|
|
@ -129,6 +129,8 @@ undef $sameFolder;
|
||||||
$sameFolder = $archive->getFolder($endOfDay);
|
$sameFolder = $archive->getFolder($endOfDay);
|
||||||
is($sameFolder->getId, $todayFolder->getId, 'call within same day(end) returns the same folder');
|
is($sameFolder->getId, $todayFolder->getId, 'call within same day(end) returns the same folder');
|
||||||
undef $sameFolder;
|
undef $sameFolder;
|
||||||
|
$todayFolder->purge;
|
||||||
|
is($archive->getChildCount, 0, 'leaving with an empty archive');
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
#
|
#
|
||||||
|
|
@ -139,6 +141,14 @@ undef $sameFolder;
|
||||||
my $child = $archive->addChild({className => 'WebGUI::Asset::Wobject::StoryTopic'});
|
my $child = $archive->addChild({className => 'WebGUI::Asset::Wobject::StoryTopic'});
|
||||||
is($child, undef, 'addChild: Will only add Stories');
|
is($child, undef, 'addChild: Will only add Stories');
|
||||||
|
|
||||||
|
$child = $archive->addChild({className => 'WebGUI::Asset::Story', title => 'First Story'});
|
||||||
|
isa_ok($child, 'WebGUI::Asset::Story', 'addChild added and returned a Story');
|
||||||
|
is($archive->getChildCount, 1, 'addChild: added it to the archive');
|
||||||
|
my $folder = $archive->getFirstChild();
|
||||||
|
isa_ok($folder, 'WebGUI::Asset::Wobject::Folder', 'Folder was added to Archive');
|
||||||
|
is($folder->getChildCount, 1, 'The folder has 1 child...');
|
||||||
|
is($folder->getFirstChild->getTitle, 'First Story', '... and it is the correct child');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue