Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
23 |
|
23 |
|
24 |
use C4::Letters qw( GetPreparedLetter EnqueueLetter ); |
24 |
use C4::Letters qw( GetPreparedLetter EnqueueLetter ); |
25 |
|
25 |
|
Lines 242-245
subtest 'patron() tests' => sub {
Link Here
|
242 |
$schema->storage->txn_rollback; |
242 |
$schema->storage->txn_rollback; |
243 |
}; |
243 |
}; |
244 |
|
244 |
|
|
|
245 |
subtest 'search_limited' => sub { |
246 |
plan tests => 2; |
247 |
|
248 |
$schema->storage->txn_begin; |
249 |
|
250 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); |
251 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } ); |
252 |
|
253 |
my $message = $builder->build_object( |
254 |
{ |
255 |
class => 'Koha::Notice::Messages', |
256 |
value => { borrowernumber => $patron->borrowernumber } |
257 |
} |
258 |
); |
259 |
|
260 |
my $message_2 = $builder->build_object( |
261 |
{ |
262 |
class => 'Koha::Notice::Messages', |
263 |
value => { borrowernumber => $patron_2->borrowernumber } |
264 |
} |
265 |
); |
266 |
|
267 |
my $nb_messages = Koha::Notice::Messages->count; |
268 |
|
269 |
my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store; |
270 |
my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store; |
271 |
Koha::Library::Group->new({ parent_id => $group_1->id, branchcode => $patron->branchcode })->store(); |
272 |
Koha::Library::Group->new({ parent_id => $group_2->id, branchcode => $patron_2->branchcode })->store(); |
273 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); # Is superlibrarian |
274 |
is( Koha::Notice::Messages->search_limited->count, $nb_messages, 'Koha::Notice::Messages->search_limited should return all generated notices for superlibrarian' ); |
275 |
t::lib::Mocks::mock_userenv( { patron => $patron_2 } ); # Is restricted |
276 |
is( Koha::Notice::Messages->search_limited->count, 1, 'Koha:Notice::Messages->search_limited should not return all generated notices for restricted patron' ); |
277 |
}; |
278 |
|
245 |
1; |
279 |
1; |