Bugzilla – Attachment 155004 Details for
Bug 32980
Checkouts for guarantees are not shown if patron also has a guarantor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32980: Make the return value of Koha::Patron::siblings consistent
Bug-32980-Make-the-return-value-of-KohaPatronsibli.patch (text/plain), 2.92 KB, created by
Julian Maurice
on 2023-08-31 12:12:45 UTC
(
hide
)
Description:
Bug 32980: Make the return value of Koha::Patron::siblings consistent
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2023-08-31 12:12:45 UTC
Size:
2.92 KB
patch
obsolete
>From 202432b2011ebe2e8dc446583da852a815d91994 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 31 Aug 2023 13:39:33 +0200 >Subject: [PATCH] Bug 32980: Make the return value of Koha::Patron::siblings > consistent > >Without the patch, Koha::Patron::siblings can return: >- undef (or an empty list in list context) if patron has no guarantors >- a Koha::Patrons object if patron has at least one guarantor, which > doesn't necessarily mean that they have siblings (they can be the only > guarantee) > >For ease of use, this subroutine should always return a Koha::Patrons >object, even if it represents an empty set. >--- > Koha/Patron.pm | 6 +--- > t/db_dependent/Koha/Patron/siblings.t | 42 +++++++++++++++++++++++++++ > 2 files changed, 43 insertions(+), 5 deletions(-) > create mode 100755 t/db_dependent/Koha/Patron/siblings.t > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 6937ea904a..e0b031499c 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -584,7 +584,7 @@ sub housebound_role { > > =head3 siblings > >-Returns the siblings of this patron. >+Returns the siblings of this patron as a C<Koha::Patrons> object > > =cut > >@@ -593,13 +593,9 @@ sub siblings { > > my @guarantors = $self->guarantor_relationships()->guarantors()->as_list; > >- return unless @guarantors; >- > my @siblings = > map { $_->guarantee_relationships()->guarantees()->as_list } @guarantors; > >- return unless @siblings; >- > my %seen; > @siblings = > grep { !$seen{ $_->id }++ && ( $_->id != $self->id ) } @siblings; >diff --git a/t/db_dependent/Koha/Patron/siblings.t b/t/db_dependent/Koha/Patron/siblings.t >new file mode 100755 >index 0000000000..1b7b7cc974 >--- /dev/null >+++ b/t/db_dependent/Koha/Patron/siblings.t >@@ -0,0 +1,42 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use String::Random; >+use Test::More tests => 1; >+ >+use Koha::Database; >+use Koha::Patrons; >+ >+my $schema = Koha::Database->schema; >+ >+subtest 'Koha::Patrons::siblings should return a Koha::Patrons object even if patron has no guarantor' => sub { >+ plan tests => 2; >+ $schema->txn_begin; >+ >+ my $random = String::Random->new; >+ >+ my $categorycode = $random->randpattern('CCCCCCCCCC'); >+ my $branchcode = $random->randpattern('CCCCCCCCCC'); >+ >+ my $category = $schema->resultset('Category')->create( { categorycode => $categorycode } ); >+ my $branch = $schema->resultset('Branch')->create( >+ { >+ branchcode => $branchcode, >+ branchname => 'Test branch for Koha::Patron::siblings tests', >+ } >+ ); >+ my $borrower = $schema->resultset('Borrower')->create( >+ { >+ categorycode => $categorycode, >+ branchcode => $branchcode, >+ } >+ ); >+ my $patron = Koha::Patrons->find( $borrower->borrowernumber ); >+ >+ my $siblings = $patron->siblings; >+ isa_ok( $siblings, 'Koha::Patrons' ); >+ is( $siblings->count, 0 ); >+ >+ $schema->txn_rollback; >+}; >-- >2.30.2
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 32980
:
146731
|
155004
|
155014
|
155015
|
155016
|
155061
|
155062
|
155063
|
155201