|
Lines 386-389
subtest 'patron() tests' => sub {
Link Here
|
| 386 |
$schema->storage->txn_rollback; |
386 |
$schema->storage->txn_rollback; |
| 387 |
}; |
387 |
}; |
| 388 |
|
388 |
|
|
|
389 |
subtest 'search_limited' => sub { |
| 390 |
plan tests => 2; |
| 391 |
|
| 392 |
$schema->storage->txn_begin; |
| 393 |
|
| 394 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); |
| 395 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } ); |
| 396 |
|
| 397 |
my $message = $builder->build_object( |
| 398 |
{ |
| 399 |
class => 'Koha::Notice::Messages', |
| 400 |
value => { borrowernumber => $patron->borrowernumber } |
| 401 |
} |
| 402 |
); |
| 403 |
|
| 404 |
my $message_2 = $builder->build_object( |
| 405 |
{ |
| 406 |
class => 'Koha::Notice::Messages', |
| 407 |
value => { borrowernumber => $patron_2->borrowernumber } |
| 408 |
} |
| 409 |
); |
| 410 |
|
| 411 |
my $nb_messages = Koha::Notice::Messages->count; |
| 412 |
|
| 413 |
my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store; |
| 414 |
my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store; |
| 415 |
Koha::Library::Group->new( { parent_id => $group_1->id, branchcode => $patron->branchcode } )->store(); |
| 416 |
Koha::Library::Group->new( { parent_id => $group_2->id, branchcode => $patron_2->branchcode } )->store(); |
| 417 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); # Is superlibrarian |
| 418 |
is( |
| 419 |
Koha::Notice::Messages->search_limited->count, $nb_messages, |
| 420 |
'Koha::Notice::Messages->search_limited should return all generated notices for superlibrarian' |
| 421 |
); |
| 422 |
t::lib::Mocks::mock_userenv( { patron => $patron_2 } ); # Is restricted |
| 423 |
is( |
| 424 |
Koha::Notice::Messages->search_limited->count, 1, |
| 425 |
'Koha:Notice::Messages->search_limited should not return all generated notices for restricted patron' |
| 426 |
); |
| 427 |
}; |
| 428 |
|
| 389 |
1; |
429 |
1; |