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 Data::Dumper;
|
||||||
|
|
||||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
|
use WebGUI::Test::Maker::Permission;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Text;
|
use WebGUI::Text;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
################################################################
|
||||||
# Init
|
#
|
||||||
|
# setup session, users and groups for this test
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
my $staff = WebGUI::Group->new($session, 'new');
|
||||||
# Tests
|
$staff->name('Reporting Staff');
|
||||||
|
|
||||||
my $tests = 0;
|
my $reporter = WebGUI::User->new($session, 'new');
|
||||||
plan tests => 1 + $tests;
|
$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
|
# put your tests here
|
||||||
|
|
@ -44,11 +71,42 @@ my $storage;
|
||||||
|
|
||||||
SKIP: {
|
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
|
# Cleanup
|
||||||
END {
|
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