#------------------------------------------------------------------- # WebGUI is Copyright 2001-2012 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 strict; use WebGUI::Test; use WebGUI::Session; use WebGUI::International; use Test::More; # increment this value for each test you create use Test::Deep; my @simpleTests = ( { method => 'adminOnly', status => 401, titleCode => 35, }, { method => 'insufficient', status => 401, titleCode => 37, }, { method => 'locked', status => 401, titleCode => 37, }, { method => 'notMember', status => 400, titleCode => 345, }, { method => 'vitalComponent', status => 403, titleCode => 40, }, { method => 'noAccess', status => 401, titleCode => 37, }, ); my $num_tests = 1; $num_tests += 3 * scalar @simpleTests; ##For each simple privilege validation $num_tests += 2; ##For noAccess as Visitor tests $num_tests += 3; ##For insufficient with noStyle=1 plan tests => $num_tests; my $session = WebGUI::Test->session; # put your tests here my $privilege = $session->privilege; my ($userTemplate) = setup_assets($session); isa_ok($privilege, 'WebGUI::Session::Privilege', 'session has correct object type'); ##Override the original user style template to make verification easier $session->setting->set('userFunctionStyleId', $userTemplate->getId); #One of the tests has different behavior depending on how it is called. #If the user is visitor, it passes them to the login screen. We'll set #the user to a different user to do simple testing on that method, then #we'll come back and do the specialized testing. $session->user({userId=>3}); my $i18n = WebGUI::International->new($session); foreach my $test (@simpleTests) { my $method = $test->{method}; my $output = $privilege->$method; is($session->response->status(), $test->{status}, "$method: status code"); my $title = $i18n->get($test->{titleCode}); like($output, qr{