From cd8e6082c1ef195b94479f39d959601a4edfbf9c Mon Sep 17 00:00:00 2001 From: Alex Sassmannshausen Date: Thu, 8 Sep 2016 12:10:45 +0200 Subject: [PATCH] Bug 5670: [Followup] Return Koha::Patron objects. * Koha/Patron/HouseboundVisit.pm (chooser, deliverer): Use `_new_from_dbic` to return Koha::Patron objects. * t/db_dependent/Patron/HouseboundVisits.t: Remove TODO section for this. Signed-off-by: Claire Gravely Signed-off-by: Kyle M Hall --- Koha/Patron/HouseboundVisit.pm | 7 +++++-- t/db_dependent/Patron/HouseboundVisits.t | 7 ++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Koha/Patron/HouseboundVisit.pm b/Koha/Patron/HouseboundVisit.pm index a7dc0c65a3..b57effef98 100644 --- a/Koha/Patron/HouseboundVisit.pm +++ b/Koha/Patron/HouseboundVisit.pm @@ -18,6 +18,7 @@ package Koha::Patron::HouseboundVisit; use Modern::Perl; use Koha::Database; +use Koha::Patron; use base qw(Koha::Object); @@ -49,7 +50,8 @@ Returns the prefetched chooser for this visit. sub chooser { my ( $self ) = @_; - return $self->_result->chooser_brwnumber; + my $rs = $self->_result->chooser_brwnumber; + return Koha::Patron->_new_from_dbic( $rs ); } =head3 deliverer @@ -62,7 +64,8 @@ Returns the prefetched deliverer for this visit. sub deliverer { my ( $self ) = @_; - return $self->_result->deliverer_brwnumber; + my $rs = $self->_result->deliverer_brwnumber; + return Koha::Patron->_new_from_dbic( $rs ); } diff --git a/t/db_dependent/Patron/HouseboundVisits.t b/t/db_dependent/Patron/HouseboundVisits.t index bec556caf9..e6f8245ee2 100644 --- a/t/db_dependent/Patron/HouseboundVisits.t +++ b/t/db_dependent/Patron/HouseboundVisits.t @@ -81,11 +81,8 @@ is( $result->deliverer->borrowernumber, $visit->{deliverer_brwnumber} ); is( $result->chooser->borrowernumber, $visit->{chooser_brwnumber} ); -TODO: { - local $TODO = "We want our results here to be Koha::Patron objects, but they by default return DBIC Schema objects. The currently accepted solution to this (use the _from_dbic method), is defined for Koha::Objects, but not for Koha::Object. We do not resolve this issue here"; - isa_ok( $result->deliverer, "Koha::Patron"); - isa_ok( $result->chooser, "Koha::Patron"); -} +isa_ok( $result->deliverer, "Koha::Patron"); +isa_ok( $result->chooser, "Koha::Patron"); $schema->storage->txn_rollback; -- 2.39.5