|
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 2324-2327
subtest 'filter_by_amount_owed' => sub {
Link Here
|
| 2324 |
|
2324 |
|
| 2325 |
}; |
2325 |
}; |
| 2326 |
|
2326 |
|
|
|
2327 |
subtest 'filter_by_have_subpermission' => sub { |
| 2328 |
plan tests => 4; |
| 2329 |
|
| 2330 |
$schema->storage->txn_begin; |
| 2331 |
|
| 2332 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 2333 |
my $patron_1 = $builder->build_object( |
| 2334 |
{ |
| 2335 |
class => 'Koha::Patrons', |
| 2336 |
value => { flags => 1, branchcode => $library->branchcode } |
| 2337 |
} |
| 2338 |
); |
| 2339 |
|
| 2340 |
my $patron_2 = $builder->build_object( # 4096 = 1 << 12 for suggestions |
| 2341 |
{ |
| 2342 |
class => 'Koha::Patrons', |
| 2343 |
value => { flags => 4096, branchcode => $library->branchcode } |
| 2344 |
} |
| 2345 |
); |
| 2346 |
|
| 2347 |
my $patron_3 = $builder->build_object( |
| 2348 |
{ |
| 2349 |
class => 'Koha::Patrons', |
| 2350 |
value => { flags => 0, branchcode => $library->branchcode } |
| 2351 |
} |
| 2352 |
); |
| 2353 |
$builder->build( |
| 2354 |
{ |
| 2355 |
source => 'UserPermission', |
| 2356 |
value => { |
| 2357 |
borrowernumber => $patron_3->borrowernumber, |
| 2358 |
module_bit => 11, |
| 2359 |
code => 'order_manage', |
| 2360 |
}, |
| 2361 |
} |
| 2362 |
); |
| 2363 |
|
| 2364 |
is_deeply( |
| 2365 |
[ |
| 2366 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2367 |
->filter_by_have_subpermission('suggestions.suggestions_manage') |
| 2368 |
->get_column('borrowernumber') |
| 2369 |
], |
| 2370 |
[ $patron_1->borrowernumber, $patron_2->borrowernumber ], |
| 2371 |
'Superlibrarian and patron with suggestions.suggestions_manage' |
| 2372 |
); |
| 2373 |
|
| 2374 |
is_deeply( |
| 2375 |
[ |
| 2376 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2377 |
->filter_by_have_subpermission('acquisition.order_manage') |
| 2378 |
->get_column('borrowernumber') |
| 2379 |
], |
| 2380 |
[ $patron_1->borrowernumber, $patron_3->borrowernumber ], |
| 2381 |
'Superlibrarian and patron with acquisition.order_manage' |
| 2382 |
); |
| 2383 |
|
| 2384 |
is_deeply( |
| 2385 |
[ |
| 2386 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2387 |
->filter_by_have_subpermission('parameters.manage_cities') |
| 2388 |
->get_column('borrowernumber') |
| 2389 |
], |
| 2390 |
[ $patron_1->borrowernumber ], |
| 2391 |
'Only Superlibrarian is returned' |
| 2392 |
); |
| 2393 |
|
| 2394 |
throws_ok { |
| 2395 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2396 |
->filter_by_have_subpermission('dont_exist.subperm'); |
| 2397 |
} 'Koha::Exceptions::ObjectNotFound'; |
| 2398 |
|
| 2399 |
|
| 2400 |
$schema->storage->txn_rollback; |
| 2401 |
}; |
| 2402 |
|
| 2327 |
$schema->storage->txn_rollback; |
2403 |
$schema->storage->txn_rollback; |
| 2328 |
- |
|
|