Bug 17568: Add the Koha::Patron->library method

This method will be convenient when moving code to Koha::Patrons

Test plan:
  prove t/db_dependent/Koha/Patrons.t
should return green

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-11-07 14:24:54 +00:00 committed by Kyle M Hall
parent 01226c61a1
commit ca5fb69362
2 changed files with 12 additions and 1 deletions

View file

@ -127,6 +127,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

View file

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 16;
use Test::More tests => 17;
use Test::Warn;
use DateTime;
@ -71,6 +71,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;