Merge branch 'asset-helpers' into 8
Conflicts: README lib/WebGUI/Role/Asset/AlwaysHidden.pm
This commit is contained in:
commit
845ede878a
24 changed files with 2089 additions and 2 deletions
76
t/AssetHelper/Copy.t
Normal file
76
t/AssetHelper/Copy.t
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Copy;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard'),
|
||||
},
|
||||
'AssetHelper/Copy redirects the back to the copied asset'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 1, '... only copied 1 asset to the clipboard, no children';
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
{
|
||||
$session->setting->set('skipCommitComments', 0);
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard'),
|
||||
open_tab => re('^'.$home->getUrl),
|
||||
},
|
||||
'AssetHelper/Copy opens a tab for commit comments'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
78
t/AssetHelper/Copy/WithChildren.t
Normal file
78
t/AssetHelper/Copy/WithChildren.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Copy::WithChildren;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithChildren->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with its children'),
|
||||
},
|
||||
'AssetHelper/Copy/WithChildren redirects the back to the copied asset'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 10, '... only copied the asset to the clipboard with children';
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
{
|
||||
$session->setting->set('skipCommitComments', 0);
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithChildren->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with its children'),
|
||||
open_tab => re('^'.$home->getUrl),
|
||||
},
|
||||
'AssetHelper/Copy/WithChildren opens a tab for commit comments'
|
||||
);
|
||||
|
||||
my $clippies = $home->getAssetsInClipboard();
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
78
t/AssetHelper/Copy/WithDescendants.t
Normal file
78
t/AssetHelper/Copy/WithDescendants.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Copy::WithDescendants;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithDescendants->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with all descendants'),
|
||||
},
|
||||
'AssetHelper/Copy/WithDescendants redirects the back to the copied asset'
|
||||
);
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 27, '... only copied the asset to the clipboard with children';
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
{
|
||||
$session->setting->set('skipCommitComments', 0);
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy::WithDescendants->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was copied to the clipboard with all descendants'),
|
||||
open_tab => re('^'.$home->getUrl),
|
||||
},
|
||||
'AssetHelper/Copy/WithDescendants opens a tab for commit comments'
|
||||
);
|
||||
|
||||
my $clippies = $home->getAssetsInClipboard();
|
||||
addToCleanup(@{ $clippies });
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
79
t/AssetHelper/Cut.t
Normal file
79
t/AssetHelper/Cut.t
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Cut;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 5; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Cut->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Cut checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Cut->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('vital component'),
|
||||
},
|
||||
'AssetHelper/Cut checks for system pages'
|
||||
);
|
||||
|
||||
my $safe_page = $home->getFirstChild;
|
||||
$output = WebGUI::AssetHelper::Cut->process($safe_page);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was cut to the clipboard'),
|
||||
redirect => $home->getUrl,
|
||||
},
|
||||
'AssetHelper/Cut returns a message and a redirect'
|
||||
);
|
||||
is $safe_page->get('state'), 'clipboard', '... and the asset was really cut';
|
||||
|
||||
$home->paste($safe_page->getId);
|
||||
|
||||
$safe_page = $safe_page->cloneFromDb();
|
||||
is $safe_page->get('state'), 'published', 'reset asset for further testing';
|
||||
|
||||
#vim:ft=perl
|
||||
91
t/AssetHelper/Demote.t
Normal file
91
t/AssetHelper/Demote.t
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Demote;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article1 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_1',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article2 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_2',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Demote->process($article1);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Demote checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Demote->process($article1);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was demoted'),
|
||||
},
|
||||
'AssetHelper/Demote returns a message'
|
||||
);
|
||||
|
||||
my $assets = $newPage->getLineage(['children'], { returnObjects => 1 });
|
||||
cmp_deeply(
|
||||
[ map { $_->getTitle } @{ $assets } ],
|
||||
[ qw{Article_2 Article_1} ],
|
||||
'... and assets were rearranged'
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
92
t/AssetHelper/Lock.t
Normal file
92
t/AssetHelper/Lock.t
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Lock;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
my $editor = WebGUI::User->create($session);
|
||||
$editor->addToGroups([4]);
|
||||
addToCleanup($editor);
|
||||
|
||||
$session->user({userId => 3});
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
groupIdEdit => '4',
|
||||
ownerUserId => '3',
|
||||
}, undef, WebGUI::Test->webguiBirthday, { skipAutoCommitWorkflows => 1, });
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$newPage = $newPage->cloneFromDb;
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Lock checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => 'Locked the asset Test page.',
|
||||
},
|
||||
'... locks the asset'
|
||||
);
|
||||
|
||||
$newPage = $newPage->cloneFromDb;
|
||||
|
||||
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
|
||||
addToCleanup($versionTag2);
|
||||
|
||||
$session->user({userId => $editor->getId});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => 'The asset Test page is already locked.',
|
||||
},
|
||||
'... returns an error message if the asset is already locked'
|
||||
);
|
||||
84
t/AssetHelper/Manage.t
Normal file
84
t/AssetHelper/Manage.t
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Manage;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 2; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article1 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_1',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article2 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_2',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Manage->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Promote checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Manage->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
open_tab => $article2->getManagerUrl,
|
||||
},
|
||||
'AssetHelper/Promote returns a message'
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
91
t/AssetHelper/Promote.t
Normal file
91
t/AssetHelper/Promote.t
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::AssetHelper::Promote;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 3; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
|
||||
my $newPage = $home->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
title => 'Test page',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article1 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_1',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
my $article2 = $newPage->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
title => 'Article_2',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, });
|
||||
|
||||
$versionTag->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Promote->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
error => re('You do not have sufficient privileges'),
|
||||
},
|
||||
'AssetHelper/Promote checks for editing privileges'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Promote->process($article2);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
message => re('was promoted'),
|
||||
},
|
||||
'AssetHelper/Promote returns a message'
|
||||
);
|
||||
|
||||
my $assets = $newPage->getLineage(['children'], { returnObjects => 1 });
|
||||
cmp_deeply(
|
||||
[ map { $_->getTitle } @{ $assets } ],
|
||||
[ qw{Article_2 Article_1} ],
|
||||
'... and assets were rearranged'
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
37
t/HTML/addToRow.t
Normal file
37
t/HTML/addToRow.t
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
plan tests => 3;
|
||||
|
||||
is WebGUI::HTML::arrayToRow(1),
|
||||
'<tr><td>1</td></tr>',
|
||||
'addToRow: 1 element';
|
||||
|
||||
is WebGUI::HTML::arrayToRow(1,2),
|
||||
'<tr><td>1</td><td>2</td></tr>',
|
||||
'... 2 elements';
|
||||
|
||||
is WebGUI::HTML::arrayToRow(),
|
||||
'<tr><td></td></tr>',
|
||||
'... 0 elements';
|
||||
Loading…
Add table
Add a link
Reference in a new issue