ProgressBar::run and now Asset->www_copy has a bar
This commit is contained in:
parent
67a66647ec
commit
503a378756
6 changed files with 394 additions and 31 deletions
|
|
@ -22,7 +22,7 @@ use WebGUI::Asset;
|
|||
use WebGUI::VersionTag;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
plan tests => 12;
|
||||
plan tests => 27;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
|
|
@ -100,3 +100,59 @@ is($topFolder->cloneFromDb->get('state'), 'clipboard', '... state set to trash i
|
|||
is($folder1a->cloneFromDb->get('state'), 'clipboard-limbo', '... state set to clipboard-limbo on child #1');
|
||||
is($folder1b->cloneFromDb->get('state'), 'clipboard-limbo', '... state set to clipboard-limbo on child #2');
|
||||
is($folder1a2->cloneFromDb->get('state'), 'clipboard-limbo', '... state set to clipboard-limbo on grandchild #1-1');
|
||||
|
||||
sub is_tree_of_folders {
|
||||
my ($asset, $depth, $pfx) = @_;
|
||||
my $recursive; $recursive = sub {
|
||||
my ($asset, $depth) = @_;
|
||||
my $pfx = " $pfx $depth";
|
||||
return 0 unless isa_ok($asset, 'WebGUI::Asset::Wobject::Folder',
|
||||
"$pfx: this object");
|
||||
|
||||
my $children = $asset->getLineage(
|
||||
['children'], {
|
||||
statesToInclude => ['clipboard', 'clipboard-limbo' ],
|
||||
returnObjects => 1,
|
||||
}
|
||||
);
|
||||
|
||||
return $depth < 2
|
||||
? is(@$children, 0, "$pfx: leaf childless")
|
||||
: is(@$children, 1, "$pfx: has child")
|
||||
&& $recursive->($children->[0], $depth - 1);
|
||||
};
|
||||
|
||||
my $pass = $recursive->($asset, $depth);
|
||||
undef $recursive;
|
||||
my $message = "$pfx is tree of folders";
|
||||
return $pass ? pass $message : fail $message;
|
||||
}
|
||||
|
||||
# test www_copy
|
||||
my $tag = WebGUI::VersionTag->create($session);
|
||||
$tag->setWorking;
|
||||
WebGUI::Test->tagsToRollback($tag);
|
||||
|
||||
my $tempspace = WebGUI::Asset->getTempspace($session);
|
||||
my $folder = {className => 'WebGUI::Asset::Wobject::Folder'};
|
||||
my $root = $tempspace->addChild($folder);
|
||||
my $child = $root->addChild($folder);
|
||||
my $grandchild = $child->addChild($folder);
|
||||
|
||||
sub copied {
|
||||
for my $a (@{$tempspace->getAssetsInClipboard}) {
|
||||
if ($a->getParent->getId eq $tempspace->getId) {
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
my @methods = qw(Single Children Descendants);
|
||||
for my $i (0..2) {
|
||||
my $meth = "_wwwCopy$methods[$i]";
|
||||
$root->$meth();
|
||||
my $clip = copied();
|
||||
is_tree_of_folders($clip, $i+1, $meth);
|
||||
$clip->purge;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue