|
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 2346-2349
subtest 'filter_by_amount_owed' => sub {
Link Here
|
| 2346 |
|
2346 |
|
| 2347 |
}; |
2347 |
}; |
| 2348 |
|
2348 |
|
|
|
2349 |
subtest 'filter_by_have_subpermission' => sub { |
| 2350 |
plan tests => 4; |
| 2351 |
|
| 2352 |
$schema->storage->txn_begin; |
| 2353 |
|
| 2354 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 2355 |
my $patron_1 = $builder->build_object( |
| 2356 |
{ |
| 2357 |
class => 'Koha::Patrons', |
| 2358 |
value => { flags => 1, branchcode => $library->branchcode } |
| 2359 |
} |
| 2360 |
); |
| 2361 |
|
| 2362 |
my $patron_2 = $builder->build_object( # 4096 = 1 << 12 for suggestions |
| 2363 |
{ |
| 2364 |
class => 'Koha::Patrons', |
| 2365 |
value => { flags => 4096, branchcode => $library->branchcode } |
| 2366 |
} |
| 2367 |
); |
| 2368 |
|
| 2369 |
my $patron_3 = $builder->build_object( |
| 2370 |
{ |
| 2371 |
class => 'Koha::Patrons', |
| 2372 |
value => { flags => 0, branchcode => $library->branchcode } |
| 2373 |
} |
| 2374 |
); |
| 2375 |
$builder->build( |
| 2376 |
{ |
| 2377 |
source => 'UserPermission', |
| 2378 |
value => { |
| 2379 |
borrowernumber => $patron_3->borrowernumber, |
| 2380 |
module_bit => 11, |
| 2381 |
code => 'order_manage', |
| 2382 |
}, |
| 2383 |
} |
| 2384 |
); |
| 2385 |
|
| 2386 |
is_deeply( |
| 2387 |
[ |
| 2388 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2389 |
->filter_by_have_subpermission('suggestions.suggestions_manage') |
| 2390 |
->get_column('borrowernumber') |
| 2391 |
], |
| 2392 |
[ $patron_1->borrowernumber, $patron_2->borrowernumber ], |
| 2393 |
'Superlibrarian and patron with suggestions.suggestions_manage' |
| 2394 |
); |
| 2395 |
|
| 2396 |
is_deeply( |
| 2397 |
[ |
| 2398 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2399 |
->filter_by_have_subpermission('acquisition.order_manage') |
| 2400 |
->get_column('borrowernumber') |
| 2401 |
], |
| 2402 |
[ $patron_1->borrowernumber, $patron_3->borrowernumber ], |
| 2403 |
'Superlibrarian and patron with acquisition.order_manage' |
| 2404 |
); |
| 2405 |
|
| 2406 |
is_deeply( |
| 2407 |
[ |
| 2408 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2409 |
->filter_by_have_subpermission('parameters.manage_cities') |
| 2410 |
->get_column('borrowernumber') |
| 2411 |
], |
| 2412 |
[ $patron_1->borrowernumber ], |
| 2413 |
'Only Superlibrarian is returned' |
| 2414 |
); |
| 2415 |
|
| 2416 |
throws_ok { |
| 2417 |
Koha::Patrons->search( { branchcode => $library->branchcode } ) |
| 2418 |
->filter_by_have_subpermission('dont_exist.subperm'); |
| 2419 |
} 'Koha::Exceptions::ObjectNotFound'; |
| 2420 |
|
| 2421 |
|
| 2422 |
$schema->storage->txn_rollback; |
| 2423 |
}; |
| 2424 |
|
| 2349 |
$schema->storage->txn_rollback; |
2425 |
$schema->storage->txn_rollback; |
| 2350 |
- |
|
|