Bugzilla – Attachment 91592 Details for
Bug 11999
Add two checks in CanBookBeReserved and CanItemBeReserved
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11999: Test improvements
Bug-11999-Test-improvements.patch (text/plain), 6.97 KB, created by
Arthur Suzuki
on 2019-07-18 14:51:46 UTC
(
hide
)
Description:
Bug 11999: Test improvements
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-07-18 14:51:46 UTC
Size:
6.97 KB
patch
obsolete
>From 96c2b9b83327c145f08bb1a10b69b5db54e6a6f6 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Thu, 18 Jul 2019 15:03:40 +0200 >Subject: [PATCH] Bug 11999: Test improvements > >improve t/db_dependent/Reserves.t to make tests pass on UNIMARC installation >--- > t/db_dependent/Holds.t | 62 +++++++++++++++++++++++++++++------------------ > t/db_dependent/Reserves.t | 6 ++++- > 2 files changed, 43 insertions(+), 25 deletions(-) > >diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t >index 1515b4bef4..225e3bdea6 100755 >--- a/t/db_dependent/Holds.t >+++ b/t/db_dependent/Holds.t >@@ -7,7 +7,7 @@ use t::lib::TestBuilder; > > use C4::Context; > >-use Test::More tests => 59; >+use Test::More tests => 62; > use MARC::Record; > > use C4::Biblio; >@@ -282,27 +282,28 @@ ok( > '... unless canreservefromotherbranches is ON (bug 2394)' > ); > >-{ >- # Regression test for bug 11336 # Test if ModReserve correctly recalculate the priorities >- $biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' }); >- ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $biblio->biblionumber); >- my $reserveid1 = AddReserve($branch_1, $borrowernumbers[0], $biblio->biblionumber, '', 1); >- ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $biblio->biblionumber); >- my $reserveid2 = AddReserve($branch_1, $borrowernumbers[1], $biblio->biblionumber, '', 2); >- ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $biblio->biblionumber); >- my $reserveid3 = AddReserve($branch_1, $borrowernumbers[2], $biblio->biblionumber, '', 3); >- my $hhh = Koha::Holds->search({ biblionumber => $biblio->biblionumber }); >- my $hold3 = Koha::Holds->find( $reserveid3 ); >- is( $hold3->priority, 3, "The 3rd hold should have a priority set to 3" ); >- ModReserve({ reserve_id => $reserveid1, rank => 'del' }); >- ModReserve({ reserve_id => $reserveid2, rank => 'del' }); >- is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); >-} >+# Regression test for bug 11336 # Test if ModReserve correctly recalculate the priorities >+$biblio = $builder->build_sample_biblio({ itemtype => 'DUMMY' }); >+($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $biblio->biblionumber); >+my $reserveid1 = AddReserve($branch_1, $borrowernumbers[0], $biblio->biblionumber, '', 1); >+($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $biblio->biblionumber); >+my $reserveid2 = AddReserve($branch_1, $borrowernumbers[1], $biblio->biblionumber, '', 2); >+($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $biblio->biblionumber); >+my $reserveid3 = AddReserve($branch_1, $borrowernumbers[2], $biblio->biblionumber, '', 3); >+my $hhh = Koha::Holds->search({ biblionumber => $biblio->biblionumber }); >+my $hold3 = Koha::Holds->find( $reserveid3 ); >+is( $hold3->priority, 3, "The 3rd hold should have a priority set to 3" ); >+ModReserve({ reserve_id => $reserveid1, rank => 'del' }); >+ModReserve({ reserve_id => $reserveid2, rank => 'del' }); >+is( $hold3->discard_changes->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); >+ >+ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); > > ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); >+$hold = Koha::Holds->find( $reserveid3 ); >+$hold->cancel; > t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); > is( CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" ); >-ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" ); > > $hold = Koha::Hold->new( > { >@@ -330,23 +331,36 @@ AddReserve( > '', > 1, > ); >+my $biblio2 = $builder->build_sample_biblio({ itemtype => 'CANNOT' }); >+my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $biblio2->biblionumber); > is( >- CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status}, 'tooManyReserves', >+ CanItemBeReserved( $borrowernumbers[0], $itemnumber2)->{status}, 'tooManyReserves', > "cannot request item if policy that matches on item-level item type forbids it" > ); >-ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber); >+ModItem({ itype => 'CAN' }, $item_bibnum2, $itemnumber2); > ok( >- CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'OK', >+ CanItemBeReserved( $borrowernumbers[0], $itemnumber2)->{status} eq 'OK', > "can request item if policy that matches on item type allows it" > ); > > t::lib::Mocks::mock_preference('item-level_itypes', 0); >-ModItem({ itype => undef }, $item_bibnum, $itemnumber); >-ok( >- CanItemBeReserved( $borrowernumbers[0], $itemnumber)->{status} eq 'tooManyReserves', >+ModItem({ itype => undef }, $item_bibnum, $itemnumber2); >+is( >+ CanItemBeReserved( $borrowernumbers[0], $itemnumber2)->{status}, 'tooManyReserves', > "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" > ); > >+is(CanBookBeReserved($borrowernumbers[0], $biblio->biblionumber)->{status}, 'OK'); >+ >+C4::Context->set_preference('maxreserves', 1); >+is(CanBookBeReserved($borrowernumbers[0], $biblio->biblionumber)->{status}, 'tooManyReserves'); >+ >+C4::Context->set_preference('maxreserves', 0); >+t::lib::Mocks::mock_preference('IndependentBranches', 1); >+t::lib::Mocks::mock_preference('canreservefromotherbranches', 0); >+ok(CanBookBeReserved($borrowernumbers[0], $foreign_biblio->biblionumber)->{status} eq 'none_available'); >+t::lib::Mocks::mock_preference('IndependentBranches', 0); >+t::lib::Mocks::mock_preference('canreservefromotherbranches', 1); > > # Test branch item rules > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 27b2701ab6..76b5baa210 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -59,7 +59,11 @@ my $frameworkcode = q//; > t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); > > # Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached >-$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode); >+$dbh->do(q| >+ INSERT INTO marc_subfield_structure (frameworkcode, tagfield, tagsubfield, kohafield) >+ VALUES ('', '521', 'a', 'biblioitems.agerestriction') >+ ON DUPLICATE KEY UPDATE kohafield = VALUES(kohafield) >+|); > my $cache = Koha::Caches->get_instance; > $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); > $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); >-- >2.11.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 11999
:
26589
|
28986
|
31524
|
35697
|
36358
|
36404
|
36630
|
38397
|
41951
|
41952
|
44631
|
44632
|
46262
|
46263
|
50224
|
50225
|
58741
|
58742
|
58743
|
63593
|
63594
|
63595
|
66267
|
66268
|
66269
|
66270
|
88300
|
88301
|
88302
|
88303
|
90142
|
90143
|
90144
|
90146
|
90147
|
91046
|
91402
|
91403
|
91479
|
91481
|
91494
|
91580
|
91581
|
91582
|
91590
|
91591
|
91592
|
91593
|
99927
|
99928
|
106481
|
106494
|
111687
|
111688
|
111689
|
112871
|
112872
|
112873
|
112874
|
120776
|
120777
|
120778
|
120779
|
120780
|
121531
|
121612