Bugzilla – Attachment 130140 Details for
Bug 29847
Koha::Patron::HouseboundProfile->housebound_visits should return a resultset
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29847: Make Koha::Patron::HouseboundProfile->housebound_visits return a resultset
Bug-29847-Make-KohaPatronHouseboundProfile-housebo.patch (text/plain), 5.41 KB, created by
Martin Renvoize (ashimema)
on 2022-02-03 13:06:18 UTC
(
hide
)
Description:
Bug 29847: Make Koha::Patron::HouseboundProfile->housebound_visits return a resultset
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-02-03 13:06:18 UTC
Size:
5.41 KB
patch
obsolete
>From 84ab4cdf069ef621fdb70788f2bce274aaace222 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 2 Feb 2022 10:35:54 -0300 >Subject: [PATCH] Bug 29847: Make > Koha::Patron::HouseboundProfile->housebound_visits return a resultset > >This patch makes the method consistent with the rest of the codebase, by >making it return a proper resultset. > >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/Patron/HouseboundProfiles.t >=> SUCCESS: Tests pass! >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests pass! >4. Check the UI hasn't got broken either. >=> SUCCESS: It hasn't! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron/HouseboundProfile.pm | 10 +- > .../prog/en/modules/members/housebound.tt | 2 +- > t/db_dependent/Patron/HouseboundProfiles.t | 96 ++++++++++--------- > 3 files changed, 55 insertions(+), 53 deletions(-) > >diff --git a/Koha/Patron/HouseboundProfile.pm b/Koha/Patron/HouseboundProfile.pm >index 612cb9afce..27427bf535 100644 >--- a/Koha/Patron/HouseboundProfile.pm >+++ b/Koha/Patron/HouseboundProfile.pm >@@ -42,17 +42,17 @@ Standard Koha::Objects definitions, and additional methods. > > =head3 housebound_visits > >- my $visits = Koha::Patron::HouseboundProfile->housebound_visits; >+ my $visits = Koha::Patron::HouseboundProfile->housebound_visits; > >-Returns an arrayref of all visits associated this houseboundProfile. >+Returns a I<Koha::Patron::HouseboundVisits> iterator for all the visits >+associated this houseboundProfile. > > =cut > > sub housebound_visits { > my ( $self ) = @_; >- my @visits = Koha::Patron::HouseboundVisits >- ->special_search({ borrowernumber => $self->borrowernumber })->as_list; >- return \@visits; >+ return Koha::Patron::HouseboundVisits >+ ->special_search({ borrowernumber => $self->borrowernumber }); > } > > =head3 _type >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt >index c08564005b..330a55c2b2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt >@@ -387,7 +387,7 @@ > <div> > <h3>Deliveries</h3> > [% housebound_visits = housebound_profile.housebound_visits %] >- [% IF housebound_visits.size > 0 %] >+ [% IF housebound_visits.count > 0 %] > <table border="0" width="100%" cellpadding="3" cellspacing="0"> > <tr> > <th>ID</th><th>Date</th><th>Chooser</th><th>Deliverer</th><th class="noExport">Actions</th> >diff --git a/t/db_dependent/Patron/HouseboundProfiles.t b/t/db_dependent/Patron/HouseboundProfiles.t >index 88a766fcc2..48e21c94d6 100755 >--- a/t/db_dependent/Patron/HouseboundProfiles.t >+++ b/t/db_dependent/Patron/HouseboundProfiles.t >@@ -17,58 +17,60 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 1; > > use Koha::Database; > use Koha::Patron::HouseboundProfiles; > > use t::lib::TestBuilder; > >-my $schema = Koha::Database->new->schema; >-$schema->storage->txn_begin; >- >+my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >-# Profile Tests >- >-my $profile = $builder->build({ source => 'HouseboundProfile' }); >- >-is( >- Koha::Patron::HouseboundProfiles >- ->find($profile->{borrowernumber})->borrowernumber, >- $profile->{borrowernumber}, >- "Find created profile." >-); >- >-my @profiles = Koha::Patron::HouseboundProfiles >- ->search({ day => $profile->{day} })->as_list; >-my $found_profile = shift @profiles; >-is( >- $found_profile->borrowernumber, >- $profile->{borrowernumber}, >- "Search for created profile." >-); >- >-# ->housebound_profile Tests >- >-my $visit1 = $builder->build({ >- source => 'HouseboundVisit', >- value => { >- borrowernumber => $profile->{borrowernumber}, >- }, >-}); >-my $visit2 = $builder->build({ >- source => 'HouseboundVisit', >- value => { >- borrowernumber => $profile->{borrowernumber}, >- }, >-}); >- >-is( >- scalar @{$found_profile->housebound_visits}, >- 2, >- "Fetch housebound_visits." >-); >- >-$schema->storage->txn_rollback; >- >+subtest 'housebound_visits() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $profile = $builder->build({ source => 'HouseboundProfile' }); >+ >+ is( >+ Koha::Patron::HouseboundProfiles >+ ->find($profile->{borrowernumber})->borrowernumber, >+ $profile->{borrowernumber}, >+ "Find created profile." >+ ); >+ >+ my @profiles = Koha::Patron::HouseboundProfiles >+ ->search({ day => $profile->{day} })->as_list; >+ my $found_profile = shift @profiles; >+ is( >+ $found_profile->borrowernumber, >+ $profile->{borrowernumber}, >+ "Search for created profile." >+ ); >+ >+ # ->housebound_profile Tests >+ >+ my $visit1 = $builder->build({ >+ source => 'HouseboundVisit', >+ value => { >+ borrowernumber => $profile->{borrowernumber}, >+ }, >+ }); >+ my $visit2 = $builder->build({ >+ source => 'HouseboundVisit', >+ value => { >+ borrowernumber => $profile->{borrowernumber}, >+ }, >+ }); >+ >+ is( >+ $found_profile->housebound_visits->count, >+ 2, >+ "Fetch housebound_visits." >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
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 29847
:
130105
| 130140