Bugzilla – Attachment 186240 Details for
Bug 39419
Holds API treats 'expiration_date' as 'patron_expiration_date'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39419: (follow-up) Unit tests
Bug-39419-follow-up-Unit-tests.patch (text/plain), 7.98 KB, created by
Brendan Lawlor
on 2025-09-05 16:58:21 UTC
(
hide
)
Description:
Bug 39419: (follow-up) Unit tests
Filename:
MIME Type:
Creator:
Brendan Lawlor
Created:
2025-09-05 16:58:21 UTC
Size:
7.98 KB
patch
obsolete
>From f6562ac4dfcb31f99987ca7babe233023f8bee89 Mon Sep 17 00:00:00 2001 >From: Brendan Lawlor <blawlor@clamsnet.org> >Date: Thu, 4 Sep 2025 17:58:31 +0000 >Subject: [PATCH] Bug 39419: (follow-up) Unit tests > >perl t/db_dependent/Reserves.t >perl t/db_dependent/api/v1/holds.t >--- > t/db_dependent/Reserves.t | 77 ++++++++++++++++++++++++++++++++++- > t/db_dependent/api/v1/holds.t | 60 +++++++++++++++++++++++---- > 2 files changed, 127 insertions(+), 10 deletions(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 79d6796f82..c2546cf9d6 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 70; >+use Test::More tests => 71; > use Test::NoWarnings; > use Test::MockModule; > use Test::Warn; >@@ -1507,7 +1507,7 @@ subtest 'IsAvailableForItemLevelRequest() tests' => sub { > > subtest 'AddReserve() tests' => sub { > >- plan tests => 2; >+ plan tests => 4; > > $schema->storage->txn_begin; > >@@ -1553,6 +1553,79 @@ subtest 'AddReserve() tests' => sub { > $patron->discard_changes; > isnt( $patron->lastseen, undef, "Patron activity tracked when hold is a valid trigger" ); > >+ my $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->id, >+ biblionumber => $biblio->id, >+ expiration_date => '2040-04-02' >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ is( $hold->expirationdate, '2040-04-02', 'Successfully set expiration date' ); >+ >+ $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->id, >+ biblionumber => $biblio->id, >+ patron_expiration_date => '2040-04-02' >+ } >+ ); >+ >+ $hold = Koha::Holds->find($reserve_id); >+ is( $hold->patron_expiration_date, '2040-04-02', 'Successfully set patron expiration date' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'ModReserve() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { lastseen => undef } } ); >+ my $biblio = $builder->build_sample_biblio; >+ >+ my $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->id, >+ biblionumber => $biblio->id, >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ ModReserve( >+ { >+ reserve_id => $hold->id, >+ branchcode => $hold->branchcode, >+ expirationdate => '2040-04-02', >+ rank => $hold->priority, >+ reservedate => $hold->reservedate, >+ } >+ ); >+ >+ $hold = Koha::Holds->find($reserve_id); >+ is( $hold->expirationdate, '2040-04-02', 'Successfully updated expiration date' ); >+ >+ ModReserve( >+ { >+ reserve_id => $reserve_id, >+ rank => $hold->priority, >+ patron_expiration_date => '2040-04-02', >+ branchcode => $hold->branchcode, >+ } >+ ); >+ >+ $hold = Koha::Holds->find($reserve_id); >+ is( $hold->patron_expiration_date, '2040-04-02', 'Successfully updated patron expiration date' ); >+ > $schema->storage->txn_rollback; > }; > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index e98d8b125e..5b6788c722 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -1207,7 +1207,7 @@ subtest 'pickup_locations() tests' => sub { > > subtest 'edit() tests' => sub { > >- plan tests => 47; >+ plan tests => 61; > > $schema->storage->txn_begin; > >@@ -1321,6 +1321,28 @@ subtest 'edit() tests' => sub { > is( $biblio_hold->reservedate, '2022-01-02', 'Hold date changed correctly' ); > is( $biblio_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' ); > >+ $biblio_hold_data = { >+ patron_expiration_date => '2022-05-02', >+ }; >+ >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id => json => $biblio_hold_data ) >+ ->status_is(200); >+ >+ $biblio_hold->discard_changes; >+ is( $biblio_hold->patron_expiration_date, '2022-05-02', 'Patron expiration date changed correctly' ); >+ >+ $biblio_hold_data = { >+ expiration_date => '2022-07-02', >+ patron_expiration_date => '2022-09-02', >+ }; >+ >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id => json => $biblio_hold_data ) >+ ->status_is(200); >+ >+ $biblio_hold->discard_changes; >+ is( $biblio_hold->expirationdate, '2022-07-02', 'Expiration date changed correctly' ); >+ is( $biblio_hold->patron_expiration_date, '2022-09-02', 'Patron expiration date changed correctly' ); >+ > # Test item-level holds > my $item_hold = $builder->build_object( > { >@@ -1383,6 +1405,24 @@ subtest 'edit() tests' => sub { > is( $item_hold->reservedate, '2022-01-02', 'Hold date changed correctly' ); > is( $item_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' ); > >+ $item_hold_data = { patron_expiration_date => '2022-05-02' }; >+ >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id => json => $item_hold_data )->status_is(200); >+ >+ $item_hold->discard_changes; >+ is( $item_hold->patron_expiration_date, '2022-05-02', 'Patron expiration date changed correctly' ); >+ >+ $item_hold_data = { >+ expiration_date => '2022-07-02', >+ patron_expiration_date => '2022-09-02', >+ }; >+ >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id => json => $item_hold_data )->status_is(200); >+ >+ $item_hold->discard_changes; >+ is( $item_hold->expirationdate, '2022-07-02', 'Expiration date changed correctly' ); >+ is( $item_hold->patron_expiration_date, '2022-09-02', 'Patron expiration date changed correctly' ); >+ > $schema->storage->txn_rollback; > > }; >@@ -1479,6 +1519,7 @@ subtest 'add() tests' => sub { > biblio_id => $biblio_hold_api_data->{biblio_id}, > patron_id => $biblio_hold_api_data->{patron_id}, > pickup_library_id => $library_1->branchcode, >+ expiration_date => '2022-11-02', > }; > > $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $biblio_hold_data )->status_is(400) >@@ -1505,9 +1546,10 @@ subtest 'add() tests' => sub { > $biblio_hold_api_data = $biblio_hold->to_api; > $biblio_hold->delete; > $biblio_hold_data = { >- biblio_id => $biblio_hold_api_data->{biblio_id}, >- patron_id => $biblio_hold_api_data->{patron_id}, >- pickup_library_id => $library_1->branchcode, >+ biblio_id => $biblio_hold_api_data->{biblio_id}, >+ patron_id => $biblio_hold_api_data->{patron_id}, >+ pickup_library_id => $library_1->branchcode, >+ patron_expiration_date => '2022-11-02', > }; > > $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $biblio_hold_data )->status_is(400) >@@ -1532,10 +1574,12 @@ subtest 'add() tests' => sub { > my $item_hold_api_data = $item_hold->to_api; > $item_hold->delete; > my $item_hold_data = { >- biblio_id => $item_hold_api_data->{biblio_id}, >- item_id => $item_hold_api_data->{item_id}, >- patron_id => $item_hold_api_data->{patron_id}, >- pickup_library_id => $library_1->branchcode, >+ biblio_id => $item_hold_api_data->{biblio_id}, >+ item_id => $item_hold_api_data->{item_id}, >+ patron_id => $item_hold_api_data->{patron_id}, >+ pickup_library_id => $library_1->branchcode, >+ expiration_date => '2022-11-02', >+ patron_expiration_date => '2022-11-02', > }; > > $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $item_hold_data )->status_is(400) >-- >2.39.5
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 39419
:
185568
|
186176
|
186177
| 186240