Bugzilla – Attachment 128761 Details for
Bug 21729
When reverting a hold the expirationdate should be reset
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21729: Add tests
Bug-21729-Add-tests.patch (text/plain), 4.69 KB, created by
Jonathan Druart
on 2021-12-20 15:04:11 UTC
(
hide
)
Description:
Bug 21729: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-12-20 15:04:11 UTC
Size:
4.69 KB
patch
obsolete
>From c6e1b60b65f4fc7326357d7bc45d988b782117fa Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 20 Dec 2021 16:03:46 +0100 >Subject: [PATCH] Bug 21729: Add tests > >--- > t/db_dependent/Koha/Holds.t | 107 +++++++++++++++++++++++++++++++++++- > 1 file changed, 106 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index 51c33832771..d3cafc8b1cf 100755 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -19,13 +19,14 @@ > > use Modern::Perl; > >-use Test::More tests => 6; >+use Test::More tests => 7; > use Test::Warn; > > use C4::Circulation qw( AddIssue ); > use C4::Reserves qw( AddReserve ModReserve ModReserveCancelAll ); > use Koha::AuthorisedValueCategory; > use Koha::Database; >+use Koha::DateUtils qw( dt_from_string ); > use Koha::Holds; > > use t::lib::Mocks; >@@ -500,6 +501,110 @@ subtest 'get_items_that_can_fill' => sub { > > }; > >+subtest 'set_waiting+patron_expiration_date' => sub { >+ plan tests => 2; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $item = >+ $builder->build_sample_item( { library => $library->branchcode } ); >+ my $manager = $builder->build_object( { class => "Koha::Patrons" } ); >+ t::lib::Mocks::mock_userenv( >+ { patron => $manager, branchcode => $manager->branchcode } ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->branchcode, } >+ } >+ ); >+ >+ subtest 'patron_expiration_date < expiration_date' => sub { >+ plan tests => 6; >+ t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', 5 ); >+ my $patron_expiration_date = dt_from_string->add( days => 3 )->ymd; >+ my $reserve_id = C4::Reserves::AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ priority => 1, >+ itemnumber => $item->itemnumber, >+ expiration_date => $patron_expiration_date, >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ is( >+ $hold->expirationdate, >+ $patron_expiration_date, >+ 'expiration date set to patron expiration date' >+ ); >+ is( >+ $hold->patron_expiration_date, $patron_expiration_date, >+ 'patron expiration date correctly set' >+ ); >+ >+ $hold->set_waiting; >+ >+ $hold = $hold->get_from_storage; >+ is( $hold->expirationdate, $patron_expiration_date ); >+ is( $hold->patron_expiration_date, $patron_expiration_date ); >+ >+ C4::Reserves::RevertWaitingStatus( >+ { itemnumber => $item->itemnumber } >+ ); >+ >+ $hold = $hold->get_from_storage; >+ is( $hold->expirationdate, $patron_expiration_date ); >+ is( $hold->patron_expiration_date, $patron_expiration_date ); >+ }; >+ >+ subtest 'patron_expiration_date > expiration_date' => sub { >+ plan tests => 6; >+ t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', 5 ); >+ my $new_expiration_date = dt_from_string->add( days => 5 )->ymd; >+ my $patron_expiration_date = dt_from_string->add( days => 6 )->ymd; >+ my $reserve_id = C4::Reserves::AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ priority => 1, >+ itemnumber => $item->itemnumber, >+ expiration_date => $patron_expiration_date, >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ is( >+ $hold->expirationdate, >+ $patron_expiration_date, >+ 'expiration date set to patron expiration date' >+ ); >+ is( >+ $hold->patron_expiration_date, $patron_expiration_date, >+ 'patron expiration date correctly set' >+ ); >+ >+ $hold->set_waiting; >+ >+ $hold = $hold->get_from_storage; >+ is( $hold->expirationdate, $new_expiration_date ); >+ is( $hold->patron_expiration_date, $patron_expiration_date ); >+ >+ C4::Reserves::RevertWaitingStatus( >+ { itemnumber => $item->itemnumber } >+ ); >+ >+ $hold = $hold->get_from_storage; >+ is( $hold->expirationdate, $patron_expiration_date ); >+ is( $hold->patron_expiration_date, $patron_expiration_date ); >+ }; >+}; >+ >+ > $schema->storage->txn_rollback; > > 1; >-- >2.25.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 21729
:
126160
|
126161
|
126162
|
126203
|
126258
|
127797
|
127798
|
127799
|
127800
|
127867
|
127868
|
127869
|
127870
|
127877
|
127878
|
127879
|
127880
|
128761
|
129090
|
129091
|
129092
|
129093
|
129094