Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 43; |
22 |
use Test::More tests => 44; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
Lines 2358-2361
subtest 'filter_by_amount_owed' => sub {
Link Here
|
2358 |
|
2358 |
|
2359 |
}; |
2359 |
}; |
2360 |
|
2360 |
|
|
|
2361 |
subtest 'filter_by_have_subpermission' => sub { |
2362 |
plan tests => 4; |
2363 |
|
2364 |
$schema->storage->txn_begin; |
2365 |
|
2366 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
2367 |
my $patron_1 = $builder->build_object( |
2368 |
{ |
2369 |
class => 'Koha::Patrons', |
2370 |
value => { flags => 1, branchcode => $library->branchcode } |
2371 |
} |
2372 |
); |
2373 |
|
2374 |
my $patron_2 = $builder->build_object( # 4096 = 1 << 12 for suggestions |
2375 |
{ |
2376 |
class => 'Koha::Patrons', |
2377 |
value => { flags => 4096, branchcode => $library->branchcode } |
2378 |
} |
2379 |
); |
2380 |
|
2381 |
my $patron_3 = $builder->build_object( |
2382 |
{ |
2383 |
class => 'Koha::Patrons', |
2384 |
value => { flags => 0, branchcode => $library->branchcode } |
2385 |
} |
2386 |
); |
2387 |
$builder->build( |
2388 |
{ |
2389 |
source => 'UserPermission', |
2390 |
value => { |
2391 |
borrowernumber => $patron_3->borrowernumber, |
2392 |
module_bit => 11, |
2393 |
code => 'order_manage', |
2394 |
}, |
2395 |
} |
2396 |
); |
2397 |
|
2398 |
is_deeply( |
2399 |
[ |
2400 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
2401 |
->filter_by_have_subpermission('suggestions.suggestions_manage') |
2402 |
->get_column('borrowernumber') |
2403 |
], |
2404 |
[ $patron_1->borrowernumber, $patron_2->borrowernumber ], |
2405 |
'Superlibrarian and patron with suggestions.suggestions_manage' |
2406 |
); |
2407 |
|
2408 |
is_deeply( |
2409 |
[ |
2410 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
2411 |
->filter_by_have_subpermission('acquisition.order_manage') |
2412 |
->get_column('borrowernumber') |
2413 |
], |
2414 |
[ $patron_1->borrowernumber, $patron_3->borrowernumber ], |
2415 |
'Superlibrarian and patron with acquisition.order_manage' |
2416 |
); |
2417 |
|
2418 |
is_deeply( |
2419 |
[ |
2420 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
2421 |
->filter_by_have_subpermission('parameters.manage_cities') |
2422 |
->get_column('borrowernumber') |
2423 |
], |
2424 |
[ $patron_1->borrowernumber ], |
2425 |
'Only Superlibrarian is returned' |
2426 |
); |
2427 |
|
2428 |
throws_ok { |
2429 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
2430 |
->filter_by_have_subpermission('dont_exist.subperm'); |
2431 |
} 'Koha::Exceptions::ObjectNotFound'; |
2432 |
|
2433 |
|
2434 |
$schema->storage->txn_rollback; |
2435 |
}; |
2436 |
|
2361 |
$schema->storage->txn_rollback; |
2437 |
$schema->storage->txn_rollback; |
2362 |
- |
|
|