Bugzilla – Attachment 113508 Details for
Bug 26963
Improve Koha::Item::pickup_locations performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26963: [GOLF] Don't delete existing data before tests
Bug-26963-GOLF-Dont-delete-existing-data-before-te.patch (text/plain), 7.77 KB, created by
Martin Renvoize (ashimema)
on 2020-11-11 15:52:58 UTC
(
hide
)
Description:
Bug 26963: [GOLF] Don't delete existing data before tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-11-11 15:52:58 UTC
Size:
7.77 KB
patch
obsolete
>From 95ed83ccd9acce1a6de7c30588f96e910c33f6d5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 11 Nov 2020 12:49:00 +0000 >Subject: [PATCH] Bug 26963: [GOLF] Don't delete existing data before tests > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Item.t | 63 ++++++++++++++++++-------------------- > 1 file changed, 29 insertions(+), 34 deletions(-) > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 3e863b69b3..401254404d 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -156,30 +156,11 @@ subtest "as_marc_field() tests" => sub { > }; > > subtest 'pickup_locations' => sub { >- plan tests => 119; > > $schema->storage->txn_begin; > > my $dbh = C4::Context->dbh; > >- # Cleanup database >- Koha::Holds->search->delete; >- $dbh->do('DELETE FROM issues'); >- Koha::Patrons->search->delete; >- Koha::Items->search->delete; >- Koha::Libraries->search->delete; >- Koha::CirculationRules->search->delete; >- Koha::CirculationRules->set_rules( >- { >- categorycode => undef, >- itemtype => undef, >- branchcode => undef, >- rules => { >- reservesallowed => 25, >- } >- } >- ); >- > my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1, branchcode => undef } } ); > my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1, branchcode => undef } } ); > my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1, } } ); >@@ -192,13 +173,12 @@ subtest 'pickup_locations' => sub { > my $group2_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } ); > my $group2_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } ); > >- my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes', value => { itemtype => 'test' } } ); >+ > my $item1 = $builder->build_sample_item( > { > homebranch => $library1->branchcode, > holdingbranch => $library2->branchcode, > barcode => '1', >- itype => 'test', > ccode => 'Gollum' > } > )->store; >@@ -208,25 +188,40 @@ subtest 'pickup_locations' => sub { > homebranch => $library3->branchcode, > holdingbranch => $library4->branchcode, > barcode => '3', >- itype => 'test', >+ itype => $item1->itype, > } > )->store; > >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ itemtype => $item1->itype, >+ branchcode => undef, >+ rules => { >+ reservesallowed => 25, >+ } >+ } >+ ); >+ >+ > my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library1->branchcode, firstname => '1' } } ); > my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } ); > >+ my $all_count = Koha::Libraries->search({ pickup_location => 1})->count(); >+ plan tests => ($all_count +1) * 7 + 31 + 60; >+ > my $results = { >- "1-1-1-any" => 3, >+ "1-1-1-any" => $all_count, > "1-1-1-holdgroup" => 2, > "1-1-1-patrongroup" => 2, > "1-1-1-homebranch" => 1, > "1-1-1-holdingbranch" => 1, >- "1-1-2-any" => 3, >+ "1-1-2-any" => $all_count, > "1-1-2-holdgroup" => 2, > "1-1-2-patrongroup" => 2, > "1-1-2-homebranch" => 1, > "1-1-2-holdingbranch" => 1, >- "1-1-3-any" => 3, >+ "1-1-3-any" => $all_count, > "1-1-3-holdgroup" => 2, > "1-1-3-patrongroup" => 2, > "1-1-3-homebranch" => 1, >@@ -236,7 +231,7 @@ subtest 'pickup_locations' => sub { > "1-4-1-patrongroup" => 0, > "1-4-1-homebranch" => 0, > "1-4-1-holdingbranch" => 0, >- "1-4-2-any" => 3, >+ "1-4-2-any" => $all_count, > "1-4-2-holdgroup" => 2, > "1-4-2-patrongroup" => 1, > "1-4-2-homebranch" => 1, >@@ -251,7 +246,7 @@ subtest 'pickup_locations' => sub { > "3-1-1-patrongroup" => 0, > "3-1-1-homebranch" => 0, > "3-1-1-holdingbranch" => 0, >- "3-1-2-any" => 3, >+ "3-1-2-any" => $all_count, > "3-1-2-holdgroup" => 1, > "3-1-2-patrongroup" => 2, > "3-1-2-homebranch" => 0, >@@ -266,12 +261,12 @@ subtest 'pickup_locations' => sub { > "3-4-1-patrongroup" => 0, > "3-4-1-homebranch" => 0, > "3-4-1-holdingbranch" => 0, >- "3-4-2-any" => 3, >+ "3-4-2-any" => $all_count, > "3-4-2-holdgroup" => 1, > "3-4-2-patrongroup" => 1, > "3-4-2-homebranch" => 0, > "3-4-2-holdingbranch" => 1, >- "3-4-3-any" => 3, >+ "3-4-3-any" => $all_count, > "3-4-3-holdgroup" => 1, > "3-4-3-patrongroup" => 1, > "3-4-3-homebranch" => 0, >@@ -365,7 +360,7 @@ subtest 'pickup_locations' => sub { > ); > > my $pickup_locations = $item1->pickup_locations( { patron => $patron1 } )->as_list; >- is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); >+ is( scalar @$pickup_locations, $all_count - 1, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); > > $builder->build_object( > { >@@ -380,11 +375,11 @@ subtest 'pickup_locations' => sub { > ); > > $pickup_locations = $item1->pickup_locations( { patron => $patron1 } )->as_list; >- is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); >+ is( scalar @$pickup_locations, $all_count - 2, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); > > t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'ccode'); > $pickup_locations = $item1->pickup_locations( { patron => $patron1 } )->as_list; >- is( scalar @$pickup_locations, 3, "With no transfer limits of type ccode we get back the libraries that are pickup locations"); >+ is( scalar @$pickup_locations, $all_count, "With no transfer limits of type ccode we get back the libraries that are pickup locations"); > > $builder->build_object( > { >@@ -399,7 +394,7 @@ subtest 'pickup_locations' => sub { > ); > > $pickup_locations = $item1->pickup_locations( { patron => $patron1 } )->as_list; >- is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); >+ is( scalar @$pickup_locations, $all_count - 1, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); > > $builder->build_object( > { >@@ -414,7 +409,7 @@ subtest 'pickup_locations' => sub { > ); > > $pickup_locations = $item1->pickup_locations( { patron => $patron1 } )->as_list; >- is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); >+ is( scalar @$pickup_locations, $all_count - 2, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); > > t::lib::Mocks::mock_preference('UseBranchTransferLimits', 0); > >-- >2.20.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 26963
:
113282
|
113283
|
113329
|
113330
|
113333
|
113339
|
113340
|
113419
|
113420
|
113422
|
113423
|
113424
|
113425
|
113451
|
113452
|
113453
|
113454
|
113455
|
113480
|
113481
|
113483
|
113498
|
113503
|
113504
|
113505
|
113506
|
113507
|
113508
|
113509
|
113510
|
113511
|
113512
|
113513
|
113514
|
113515
|
113516
|
113517
|
113518
|
113519
|
113520
|
113521
|
113523
|
113524
|
113525
|
113526
|
113527
|
113528
|
113529
|
113530
|
113531
|
113586
|
113729