my $branch = $builder->build({ source => 'Branch' });
my $category = $builder->build({ source => 'Category' });
-my $patron = Koha::Patron->new(
- {
+my $patron = $builder->build_object({
+ class => 'Koha::Patrons',
+ value => {
categorycode => $category->{categorycode},
branchcode => $branch->{branchcode},
flags => 1,# superlibrarian
- userid => 'a_userid_for_tests', # So far Koha::Patron->store does not deal with userid, see bug 20287
- }
-)->store();
+ },
+});
ok( $patron->id, 'Koha::Patron created' );
-my $patron_2 = $builder->build({ source => 'Borrower', value => { flags => 0 } });
-$patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} );
+my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 0 } });
# store
Koha::Notice::Messages->delete;
$rule->delete();
subtest 'search_limited' => sub {
- plan tests => 4;
+ plan tests => 2;
C4::Context->_new_userenv('xxx');
my $nb_article_requests = Koha::ArticleRequests->count;
Koha::Library::Group->new({ parent_id => $group_1->id, branchcode => $patron->branchcode })->store();
Koha::Library::Group->new({ parent_id => $group_2->id, branchcode => $patron_2->branchcode })->store();
set_logged_in_user( $patron ); # Is superlibrarian
- is( Koha::ArticleRequests->count, $nb_article_requests, 'Koha::ArticleRequests should return all article requests' );
is( Koha::ArticleRequests->search_limited->count, $nb_article_requests, 'Koha::ArticleRequests->search_limited should return all article requests for superlibrarian' );
set_logged_in_user( $patron_2 ); # Is restricted
- is( Koha::ArticleRequests->count, $nb_article_requests, 'Koha::ArticleRequests should return all article requests' );
is( Koha::ArticleRequests->search_limited->count, 0, 'Koha::ArticleRequests->search_limited should not return all article requests for restricted patron' );
};