test canPostStories method
This commit is contained in:
parent
2345c6a2d1
commit
2ce2155321
1 changed files with 65 additions and 7 deletions
|
|
@ -21,18 +21,45 @@ use Test::Deep;
|
|||
use Data::Dumper;
|
||||
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Text;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
################################################################
|
||||
#
|
||||
# setup session, users and groups for this test
|
||||
#
|
||||
################################################################
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
my $staff = WebGUI::Group->new($session, 'new');
|
||||
$staff->name('Reporting Staff');
|
||||
|
||||
my $tests = 0;
|
||||
plan tests => 1 + $tests;
|
||||
my $reporter = WebGUI::User->new($session, 'new');
|
||||
$reporter->username('reporter');
|
||||
my $editor = WebGUI::User->new($session, 'new');
|
||||
$editor->username('editor');
|
||||
my $reader = WebGUI::User->new($session, 'new');
|
||||
$reader->username('reader');
|
||||
$staff->addUsers([$reporter->userId]);
|
||||
|
||||
my $archive = 'placeholder for Test::Maker::Permission';
|
||||
|
||||
my $canPostMaker = WebGUI::Test::Maker::Permission->new();
|
||||
$canPostMaker->prepare({
|
||||
object => $archive,
|
||||
session => $session,
|
||||
method => 'canPostStories',
|
||||
pass => [3, $editor, $reporter ],
|
||||
fail => [1, $reader ],
|
||||
});
|
||||
|
||||
my $tests = 1;
|
||||
plan tests => 2
|
||||
+ $tests
|
||||
+ $canPostMaker->plan
|
||||
;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -44,11 +71,42 @@ my $storage;
|
|||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load module $class", $tests unless $loaded;
|
||||
skip "Unable to load module $class", $tests unless $loaded;
|
||||
|
||||
$archive = WebGUI::Asset->getDefault($session)->addChild({className => $class});
|
||||
|
||||
isa_ok($archive, 'WebGUI::Asset::Wobject::StoryArchive', 'created StoryArchive');
|
||||
|
||||
################################################################
|
||||
#
|
||||
# canPostStories
|
||||
#
|
||||
################################################################
|
||||
|
||||
$archive->update({
|
||||
ownerUserId => $editor->userId,
|
||||
groupToPost => $staff->getId,
|
||||
});
|
||||
|
||||
is($archive->get('groupToPost'), $staff->getId, 'set Staff group to post to Story Archive');
|
||||
|
||||
$canPostMaker->{_tests}->[0]->{object} = $archive;
|
||||
|
||||
$canPostMaker->run();
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
if (defined $archive and ref $archive eq $class) {
|
||||
$archive->purge;
|
||||
}
|
||||
WebGUI::VersionTag->getWorking($session)->rollback;
|
||||
foreach my $user ($editor, $reporter, $reader) {
|
||||
$user->delete if defined $user;
|
||||
}
|
||||
foreach my $group ($staff) {
|
||||
$group->delete if defined $group;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue