Bugzilla – Attachment 184646 Details for
Bug 40517
Allow grouping existing holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40517: Add unit tests
Bug-40517-Add-unit-tests.patch (text/plain), 5.64 KB, created by
Pedro Amorim
on 2025-07-25 14:38:45 UTC
(
hide
)
Description:
Bug 40517: Add unit tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-07-25 14:38:45 UTC
Size:
5.64 KB
patch
obsolete
>From 87e17d783df7303c70fa0bbc48d05266451a0973 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Fri, 25 Jul 2025 13:59:23 +0000 >Subject: [PATCH] Bug 40517: Add unit tests > >Run the updated test file: >prove ./t/db_dependent/Koha/Patron.t > >Relevant tests worth running to ensure no regressions are added to existing covered functionality: >prove ./t/db_dependent/Circulation* >prove ./t/db_dependent/Hold* >prove ./t/db_dependent/Reserves* > >Test plan, k-t-d: >1) Apply patches, enable DisplayAddHoldGroups system preference >2) Do a search for 'test': ><staff_url>/cgi-bin/koha/catalogue/search.pl?q=test >3) Click the 'Select all' link at the top of the search results, click the 'Place hold' button. >4) Enter the 'koha' user >5) Pick a pickup location for each of the holds and click 'Place holds'. >6) Visit the 'koha' patron: ><staff_url>/cgi-bin/koha/members/moremember.pl?borrowernumber=51 >7) Click the 'holds' tab. Notice a new 'Group selected' button now exists >8) Pick any number of holds (more than 2) and click the 'Group selected' button. Confirm >9) Notice the hold group shows '1'. If you click on it you're presented the hold group modal. >10) Group multiple holds multiple times. >11) Notice you can't group a hold that has already been found. >12) Notice you can't click the 'Group selected' button unless at least 2 holds are selected. >13) Notice a hold group is deleted if left with 0 or 1 hold e.g. make a group of 2 holds, cancel 1, notice the remaining hold is left without a group. > >prove t/db_dependent/api/v1/patrons_hold_groups.t >prove t/db_dependent/Koha/Patron.t >--- > t/db_dependent/Koha/Patron.t | 90 +++++++++++++++++++++++++++++++++++- > 1 file changed, 89 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 7cba994728a..f1d717ef8e4 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 42; >+use Test::More tests => 43; > use Test::NoWarnings; > use Test::Exception; > use Test::Warn; >@@ -3118,3 +3118,91 @@ subtest 'is_anonymous' => sub { > $schema->storage->txn_rollback; > > }; >+ >+subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { >+ >+ plan tests => 13; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $hold1 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ my $hold2 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ my $hold3 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ >+ my $hold4 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ my $hold5 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ >+ my $hold6 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } >+ } >+ ); >+ >+ my $patron_hold_groups = $patron->hold_groups; >+ is( $patron_hold_groups->count, 0, 'Patron does not have any hold groups' ); >+ >+ # Create 1st hold group >+ $patron->create_hold_group( [ $hold1->reserve_id, $hold2->reserve_id, $hold3->reserve_id ] ); >+ is( $patron_hold_groups->count, 1, 'Patron has one hold group' ); >+ >+ my $hold_group = $patron->hold_groups->as_list->[0]; >+ is( $hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); >+ is( $hold_group->hold_group_id, $hold1->get_from_storage->hold_group_id, 'hold1 added to hold_group' ); >+ is( $hold_group->hold_group_id, $hold2->get_from_storage->hold_group_id, 'hold2 added to hold_group' ); >+ is( $hold_group->hold_group_id, $hold3->get_from_storage->hold_group_id, 'hold3 added to hold_group' ); >+ >+ # Create 2nd hold group >+ $patron->create_hold_group( [ $hold4->reserve_id, $hold5->reserve_id ] ); >+ is( $patron_hold_groups->count, 2, 'Patron has two hold groups' ); >+ >+ my $second_hold_group = $patron->hold_groups->as_list->[1]; >+ is( $second_hold_group->visual_hold_group_id, 2, 'Visual hold group id is 2' ); >+ is( >+ $second_hold_group->hold_group_id, $hold4->get_from_storage->hold_group_id, >+ 'hold4 added to second hold_group' >+ ); >+ is( >+ $second_hold_group->hold_group_id, $hold5->get_from_storage->hold_group_id, >+ 'hold5 added to second hold_group' >+ ); >+ >+ $hold3->get_from_storage->fill(); >+ is( $patron->get_from_storage->hold_groups->count, 1, 'Patron only has one hold group again' ); >+ >+ $hold4->get_from_storage->cancel(); >+ is( $patron->get_from_storage->hold_groups->count, 0, 'Patron does not have any hold groups again' ); >+ >+ # Create 3rd hold group >+ $patron->create_hold_group( [ $hold5->reserve_id, $hold6->reserve_id ] ); >+ my $third_hold_group = $patron->hold_groups->as_list->[0]; >+ is( $third_hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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 40517
:
184640
|
184641
|
184642
|
184643
|
184644
|
184645
| 184646