@@ -, +, @@ prove t/db_dependent/Koha/Patrons.t --- Koha/Patron.pm | 5 +++++ t/db_dependent/Koha/Patrons.t | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) --- a/Koha/Patron.pm +++ a/Koha/Patron.pm @@ -113,6 +113,11 @@ sub image { return Koha::Patron::Images->find( $self->borrowernumber ) } +sub library { + my ( $self ) = @_; + return Koha::Library->_new_from_dbic($self->_result->branchcode) +} + =head3 guarantees Returns the guarantees (list of Koha::Patron) of this patron --- a/t/db_dependent/Koha/Patrons.t +++ a/t/db_dependent/Koha/Patrons.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 12; use Test::Warn; use C4::Members; @@ -68,6 +68,12 @@ is( Koha::Patrons->search->count, $nb_of_patrons + 2, 'The 2 patrons should have my $retrieved_patron_1 = Koha::Patrons->find( $new_patron_1->borrowernumber ); is( $retrieved_patron_1->cardnumber, $new_patron_1->cardnumber, 'Find a patron by borrowernumber should return the correct patron' ); +subtest 'library' => sub { + plan tests => 2; + is( $retrieved_patron_1->library->branchcode, $library->{branchcode}, 'Koha::Patron->library should return the correct library' ); + is( ref($retrieved_patron_1->library), 'Koha::Library', 'Koha::Patron->library should return a Koha::Library object' ); +}; + subtest 'guarantees' => sub { plan tests => 8; my $guarantees = $new_patron_1->guarantees; --