use Koha::Database;
use t::lib::TestBuilder;
-use C4::Auth qw(haspermission);
+use C4::Auth qw( haspermission );
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
},
}
);
+my $borr3 = $builder->build(
+ {
+ source => 'Borrower',
+ value => {
+ surname => 'Bor2',
+ flags => 2**13, # top level tools
+ },
+ }
+);
$builder->build(
{
source => 'UserPermission',
subtest 'undef top level tests' => sub {
- plan tests => 2;
+ plan tests => 1;
+
+ my $pass = haspermission( $borr2->{userid} );
+ ok($pass, "let through undef privs");
- throws_ok { my $r = haspermission( $borr1->{userid} ); }
- 'Koha::Exceptions::WrongParameter',
- 'Exception thrown when missing $requiredflags';
- throws_ok { my $r = haspermission( $borr1->{userid}, undef ); }
- 'Koha::Exceptions::WrongParameter', 'Exception thrown when explicit undef';
+ #throws_ok { my $r = haspermission( $borr1->{userid} ); }
+ #'Koha::Exceptions::WrongParameter',
+ # 'Exception thrown when missing $requiredflags';
+ #throws_ok { my $r = haspermission( $borr1->{userid}, undef ); }
+ #'Koha::Exceptions::WrongParameter', 'Exception thrown when explicit undef';
};
subtest 'scalar top level tests' => sub {
subtest 'hashref top level AND tests' => sub {
- plan tests => 15;
+ plan tests => 16;
# Check top level permission for superlibrarian
my $r =
);
is( ref($r), 'HASH', 'Borrower2 (/tools|upload_local_cover_image AND /tools|batch_upload_patron_images) granular' );
$r = haspermission(
+ $borr3->{userid},
+ {
+ tools => {
+ 'upload_local_cover_images' => 1,
+ 'batch_upload_patron_images' => 1
+ },
+ }
+ );
+ is( ref($r), 'HASH', 'Borrower3 (/tools|upload_local_cover_image AND /tools|batch_upload_patron_images) granular' );
+ $r = haspermission(
$borr2->{userid},
{
tools => {