Bugzilla – Attachment 165185 Details for
Bug 36120
Add pickup locations to bookings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36120: Unit tests for pickup_locations change
Bug-36120-Unit-tests-for-pickuplocations-change.patch (text/plain), 5.39 KB, created by
Martin Renvoize (ashimema)
on 2024-04-19 13:34:02 UTC
(
hide
)
Description:
Bug 36120: Unit tests for pickup_locations change
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-19 13:34:02 UTC
Size:
5.39 KB
patch
obsolete
>From 515dc9771222f0d184c8866dc470b72d17336c60 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 21 Mar 2024 12:52:57 +0000 >Subject: [PATCH] Bug 36120: Unit tests for pickup_locations change > >This patch adds unit tests for the additional caching of location_items >in the pickup_locations method of Koha::Biblio. >--- > t/db_dependent/Koha/Biblio.t | 84 ++++++++++++++++++++++++++++-------- > 1 file changed, 65 insertions(+), 19 deletions(-) > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index d6cd9995d43..2e229d11e5f 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -243,7 +243,7 @@ subtest 'is_serial() tests' => sub { > > subtest 'pickup_locations() tests' => sub { > >- plan tests => 11; >+ plan tests => 19; > > $schema->storage->txn_begin; > >@@ -442,31 +442,77 @@ subtest 'pickup_locations() tests' => sub { > "PatronLibrary-2-8" => 3, > }; > >+ my $items_results = { >+ "ItemHomeLibrary-1-1" => { >+ $library1->branchcode => [ $item1_1->itemnumber ], >+ $library2->branchcode => [ $item1_1->itemnumber ], >+ $library4->branchcode => [ $item1_1->itemnumber ], >+ $library5->branchcode => [ $item1_1->itemnumber ], >+ $library6->branchcode => [ $item1_1->itemnumber ], >+ $library7->branchcode => [ $item1_1->itemnumber ] >+ }, >+ "ItemHomeLibrary-1-8" => { >+ $library4->branchcode => [ $item1_7->itemnumber ], >+ }, >+ "ItemHomeLibrary-2-1" => { >+ $library1->branchcode => [ $item2_2->itemnumber ], >+ $library2->branchcode => [ $item2_2->itemnumber ], >+ }, >+ "ItemHomeLibrary-2-8" => {}, >+ "PatronLibrary-1-1" => { >+ $library1->branchcode => [ $item1_1->itemnumber ], >+ $library2->branchcode => [ $item1_1->itemnumber ], >+ $library4->branchcode => [ $item1_1->itemnumber ], >+ $library5->branchcode => [ $item1_1->itemnumber ], >+ $library6->branchcode => [ $item1_1->itemnumber ], >+ $library7->branchcode => [ $item1_1->itemnumber ] >+ }, >+ "PatronLibrary-1-8" => { >+ $library5->branchcode => [ $item1_1->itemnumber, $item1_3->itemnumber, $item1_7->itemnumber ], >+ $library6->branchcode => [ $item1_1->itemnumber, $item1_3->itemnumber, $item1_7->itemnumber ], >+ $library7->branchcode => [ $item1_1->itemnumber, $item1_3->itemnumber, $item1_7->itemnumber ], >+ }, >+ "PatronLibrary-2-1" => {}, >+ "PatronLibrary-2-8" => { >+ $library5->branchcode => [ $item2_2->itemnumber, $item2_4->itemnumber, $item2_6->itemnumber ], >+ $library6->branchcode => [ $item2_2->itemnumber, $item2_4->itemnumber, $item2_6->itemnumber ], >+ $library7->branchcode => [ $item2_2->itemnumber, $item2_4->itemnumber, $item2_6->itemnumber ], >+ } >+ }; >+ > sub _doTest { >- my ( $cbranch, $biblio, $patron, $results ) = @_; >- t::lib::Mocks::mock_preference('ReservesControlBranch', $cbranch); >+ my ( $cbranch, $biblio, $patron, $results, $items_results ) = @_; >+ t::lib::Mocks::mock_preference( 'ReservesControlBranch', $cbranch ); >+ >+ my $pl = $biblio->pickup_locations( { patron => $patron } ); > >+ # Filter to just test branches > my @pl = map { > my $pickup_location = $_; > grep { $pickup_location->branchcode eq $_ } @branchcodes >- } $biblio->pickup_locations( { patron => $patron } )->as_list; >+ } $pl->as_list; > > ok( >- scalar(@pl) == $results->{ $cbranch . '-' >- . $biblio->title . '-' >- . $patron->firstname }, >+ scalar(@pl) == $results->{ $cbranch . '-' . $biblio->title . '-' . $patron->firstname }, > 'ReservesControlBranch: ' >- . $cbranch >- . ', biblio' >- . $biblio->title >- . ', patron' >- . $patron->firstname >- . ' should return ' >- . $results->{ $cbranch . '-' >- . $biblio->title . '-' >- . $patron->firstname } >- . ' but returns ' >- . scalar(@pl) >+ . $cbranch >+ . ', biblio' >+ . $biblio->title >+ . ', patron' >+ . $patron->firstname >+ . ' should return ' >+ . $results->{ $cbranch . '-' . $biblio->title . '-' . $patron->firstname } >+ . ' and returns ' >+ . scalar(@pl) >+ ); >+ >+ my %filtered_location_items = map { $_ => $pl->{_pickup_location_items}->{$_} } >+ grep { exists $pl->{_pickup_location_items}->{$_} } @branchcodes; >+ >+ is_deeply( >+ \%filtered_location_items, \%{ $items_results->{ $cbranch . '-' >+ . $biblio->title . '-' >+ . $patron->firstname } }, 'Items per location correctly cached in resultset' > ); > } > >@@ -475,7 +521,7 @@ subtest 'pickup_locations() tests' => sub { > $cache->flush(); # needed since we change ReservesControlBranch > foreach my $biblio ($biblio1, $biblio2) { > foreach my $patron ($patron1, $patron8) { >- _doTest($cbranch, $biblio, $patron, $results); >+ _doTest($cbranch, $biblio, $patron, $results, $items_results); > } > } > } >-- >2.44.0
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 36120
:
162911
|
162912
|
162914
|
162915
|
162916
|
162917
|
162918
|
162919
|
162920
|
162921
|
162922
|
162923
|
162924
|
162925
|
162926
|
162927
|
162928
|
162976
|
163218
|
163219
|
163220
|
163221
|
163222
|
163223
|
163224
|
163435
|
163436
|
163437
|
163438
|
163439
|
163440
|
163441
|
163442
|
163443
|
163444
|
163445
|
163446
|
163447
|
163448
|
163565
|
163566
|
163567
|
163568
|
163569
|
163570
|
163571
|
163603
|
163604
|
163605
|
163606
|
163607
|
163608
|
163609
|
163610
|
163611
|
163612
|
163613
|
163635
|
163636
|
165140
|
165175
|
165176
|
165177
|
165178
|
165179
|
165180
|
165181
|
165182
|
165183
|
165184
|
165185
|
165186
|
165187
|
165188
|
165214
|
165215
|
165216
|
165419
|
165420
|
165421
|
165422
|
165423
|
165424
|
165425
|
165426
|
165427
|
165428
|
165429
|
165430
|
165431
|
165432
|
165433
|
165434
|
165435
|
165984
|
165985
|
165986
|
165987
|
165988
|
165989
|
165990
|
165991
|
165992
|
165993
|
165994
|
165995
|
165996
|
165997
|
165998
|
165999
|
166000
|
166001
|
166002