Bugzilla – Attachment 144839 Details for
Bug 32529
Holds in processing should block item deletion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32529: Add Koha::Holds->filter_by_found
Bug-32529-Add-KohaHolds-filterbyfound.patch (text/plain), 2.87 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-12-26 18:31:50 UTC
(
hide
)
Description:
Bug 32529: Add Koha::Holds->filter_by_found
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-12-26 18:31:50 UTC
Size:
2.87 KB
patch
obsolete
>From 5d884d043e90f95a6a80d7780fe8b284e664ea9a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 26 Dec 2022 13:02:25 -0300 >Subject: [PATCH] Bug 32529: Add Koha::Holds->filter_by_found > >This patch adds a method for filtering Koha::Holds resultsets by the >status belonging to Koha's concept of 'found'. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Holds.t >=> SUCCESS: Tests pass! >3. Sign off :-D >--- > Koha/Holds.pm | 13 +++++++++++++ > t/db_dependent/Koha/Holds.t | 32 +++++++++++++++++++++++++++++++- > 2 files changed, 44 insertions(+), 1 deletion(-) > >diff --git a/Koha/Holds.pm b/Koha/Holds.pm >index b53b95735a7..d4e0b5cdc66 100644 >--- a/Koha/Holds.pm >+++ b/Koha/Holds.pm >@@ -34,8 +34,21 @@ Koha::Holds - Koha Hold object set class > > =head2 Class methods > >+=head3 filter_by_found >+ >+ my $found_holds = $holds->filter_by_found; >+ >+Returns a filtered resultset without holds that are considered I<found>. >+i.e. 'P', 'T' and 'W'. >+ > =cut > >+sub filter_by_found { >+ my ($self) = @_; >+ >+ return $self->search( { found => [ 'P', 'T', 'W' ] } ); >+} >+ > =head3 waiting > > returns a set of holds that are waiting from an existing set >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index b292672a1cf..57f1d969350 100755 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >+use Test::More tests => 11; > use Test::Warn; > > use C4::Circulation qw( AddIssue ); >@@ -670,6 +670,36 @@ subtest 'Test Koha::Hold::item_group' => sub { > > $schema->storage->txn_rollback; > >+subtest 'filter_by_found() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $unfilled = $builder->build_object( { class => 'Koha::Holds', value => { found => undef } } ); >+ my $processing = $builder->build_object( { class => 'Koha::Holds', value => { found => 'P' } } ); >+ my $in_transit = $builder->build_object( { class => 'Koha::Holds', value => { found => 'T' } } ); >+ my $waiting = $builder->build_object( { class => 'Koha::Holds', value => { found => 'W' } } ); >+ >+ my $holds = Koha::Holds->search( >+ { reserve_id => [ $unfilled->id, $processing->id, $in_transit->id, $waiting->id ] }, >+ { order_by => ['reserve_id'] } >+ ); >+ >+ is( $holds->count, 4, 'Resultset count is correct' ); >+ >+ my $found_holds = $holds->filter_by_found; >+ >+ is( $found_holds->count, 3, 'Resultset count is correct' ); >+ >+ ok( $found_holds->next->is_in_processing, 'Status is correct (P)' ); >+ ok( $found_holds->next->is_in_transit, 'Status is correct (T)' ); >+ ok( $found_holds->next->is_waiting, 'Status is correct (W)' ); >+ >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_requests() tests' => sub { > > plan tests => 7; >-- >2.34.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 32529
:
144839
|
144840
|
144841
|
144848
|
144849
|
144850
|
144874
|
144875
|
144876