@@ -, +, @@ prove t/db_dependent/Koha/Checkouts.t --- Koha/Checkout.pm | 14 ++++++++++++++ t/db_dependent/Koha/Checkouts.t | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) --- a/Koha/Checkout.pm +++ a/Koha/Checkout.pm @@ -74,6 +74,20 @@ sub item { return Koha::Item->_new_from_dbic( $item_rs ); } +=head3 patron + +my $patron = $checkout->patron + +Return the patron for who the checkout has been done + +=cut + +sub patron { + my ( $self ) = @_; + my $patron_rs = $self->_result->borrower; + return Koha::Patron->_new_from_dbic( $patron_rs ); +} + =head3 type =cut --- a/t/db_dependent/Koha/Checkouts.t +++ a/t/db_dependent/Koha/Checkouts.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 6; +use Test::More tests => 7; use Koha::Checkouts; use Koha::Database; @@ -93,6 +93,13 @@ subtest 'item' => sub { is( $item->itemnumber, $item_1->{itemnumber}, 'Koha::Checkout->item should return the correct item' ); }; +subtest 'patron' => sub { + plan tests => 2; + my $p = $new_checkout_1->patron; + is( ref($p), 'Koha::Patron', 'Koha::Checkout->patron should return a Koha::Patron' ); + is( $p->borrowernumber, $patron->{borrowernumber}, 'Koha::Checkout->patron should return the correct patron' ); +}; + $retrieved_checkout_1->delete; is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); --