Bugzilla – Attachment 57971 Details for
Bug 17584
Add the Koha::Patron->checkouts method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17584: Add the Koha::Patron->get_issues method
Bug-17584-Add-the-KohaPatron-getissues-method.patch (text/plain), 3.45 KB, created by
Jonathan Druart
on 2016-12-05 15:33:27 UTC
(
hide
)
Description:
Bug 17584: Add the Koha::Patron->get_issues method
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-12-05 15:33:27 UTC
Size:
3.45 KB
patch
obsolete
>From 2708b1254e8c507da1952cc772cb70e5d8e504fd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 8 Nov 2016 12:52:52 +0000 >Subject: [PATCH] Bug 17584: Add the Koha::Patron->get_issues method > >Test plan: > prove t/db_dependent/Koha/Patrons.t >should return green > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/Patron.pm | 16 +++++++++++++--- > t/db_dependent/Koha/Patrons.t | 17 +++++++++++++---- > 2 files changed, 26 insertions(+), 7 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index a40d6f0..51dbb5b 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -496,6 +496,18 @@ sub add_enrolment_fee_if_needed { > return $enrolment_fee || 0; > } > >+=head3 get_issues >+ >+my $issues = $patron->get_issues >+ >+=cut >+ >+sub get_issues { >+ my ($self) = @_; >+ my $issues = $self->_result->issues; >+ return Koha::Issues->_new_from_dbic( $issues ); >+} >+ > =head3 get_overdues > > my $overdue_items = $patron->get_overdues >@@ -507,16 +519,14 @@ Return the overdued items > sub get_overdues { > my ($self) = @_; > my $dtf = Koha::Database->new->schema->storage->datetime_parser; >- my $issues = Koha::Issues->search( >+ return $self->get_issues->search( > { >- 'me.borrowernumber' => $self->borrowernumber, > 'me.date_due' => { '<' => $dtf->format_datetime(dt_from_string) }, > }, > { > prefetch => { item => { biblio => 'biblioitems' } }, > } > ); >- return $issues; > } > > =head3 type >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 1a9a1ea..33286ae 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 14; >+use Test::More tests => 15; > use Test::Warn; > use DateTime; > >@@ -406,8 +406,8 @@ subtest 'add_enrolment_fee_if_needed' => sub { > $patron->delete; > }; > >-subtest 'get_overdues' => sub { >- plan tests => 4; >+subtest 'get_issues + get_overdues' => sub { >+ plan tests => 8; > > my $library = $builder->build( { source => 'Branch' } ); > my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); >@@ -449,8 +449,13 @@ subtest 'get_overdues' => sub { > } > ); > >+ $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ my $issues = $patron->get_issues; >+ is( $issues->count, 0, 'get_issues should not return any issues for that patron' ); >+ is( ref($issues), 'Koha::Issues', 'get_issues should return a Koha::Issues object' ); >+ > # Not sure how this is useful, but AddIssue pass this variable to different other subroutines >- $patron = GetMember( borrowernumber => $patron->{borrowernumber} ); >+ $patron = GetMember( borrowernumber => $patron->borrowernumber ); > > my $module = new Test::MockModule('C4::Context'); > $module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); >@@ -460,6 +465,10 @@ subtest 'get_overdues' => sub { > AddIssue( $patron, $item_3->{barcode} ); > > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ $issues = $patron->get_issues; >+ is( $issues->count, 3, 'get_issues should return 3 issues for that patron' ); >+ is( ref($issues), 'Koha::Issues', 'get_issues should return a Koha::Issues object' ); >+ > my $overdues = $patron->get_overdues; > is( $overdues->count, 2, 'Patron should have 2 overdues'); > is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' ); >-- >2.9.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17584
:
57331
|
57365
|
57971
|
58295
|
58419
|
58420