Bugzilla – Attachment 106564 Details for
Bug 22806
CanBookBeReserve and CanItemBeReserve do not check AllowHoldsOnPatronsPossessions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22806: Unit Tests
Bug-22806-Unit-Tests.patch (text/plain), 4.83 KB, created by
Arthur Suzuki
on 2020-07-05 20:28:55 UTC
(
hide
)
Description:
Bug 22806: Unit Tests
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2020-07-05 20:28:55 UTC
Size:
4.83 KB
patch
obsolete
>From c2fbc008a8764a65e174a873fbb88dd96b0c45ae Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Wed, 8 Jan 2020 14:20:38 +0100 >Subject: [PATCH] Bug 22806: Unit Tests > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/ILSDI_Services.t | 20 ++++++++++++++++++-- > t/db_dependent/Reserves.t | 40 +++++++++++++++++++++++++++++++++++++++- > 2 files changed, 57 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 3f253149e3..090701ee44 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -300,7 +300,7 @@ subtest 'LookupPatron test' => sub { > > subtest 'Holds test' => sub { > >- plan tests => 5; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -417,6 +417,7 @@ subtest 'Holds test' => sub { > source => 'Item', > value => { > biblionumber => $biblio3->{biblionumber}, >+ barcode => '123456789', > damaged => 0, > itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype, > } >@@ -449,6 +450,21 @@ subtest 'Holds test' => sub { > $reply = C4::ILSDI::Services::HoldItem( $query ); > is( $reply->{code}, 'damaged', "Item is damaged" ); > >+ $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $module = new Test::MockModule('C4::Context'); >+ $module->mock('userenv', sub { { patron => $patron } }); >+ my $date_due = Koha::DateUtils::dt_from_string()->add(weeks => 2); >+ my $issue = C4::Circulation::AddIssue($patron->unblessed, $item3->{barcode}, $date_due); >+ t::lib::Mocks::mock_preference( 'AllowHoldsOnPatronsPossessions', '0' ); >+ >+ $query->param( 'patron_id', $patron->borrowernumber); >+ $query->param( 'bib_id', $biblio3->{biblionumber}); >+ $query->param( 'item_id', $item3->{itemnumber}); >+ $reply = C4::ILSDI::Services::HoldItem( $query ); >+ >+ is( $reply->{code}, 'itemAlreadyOnLoan', "Patron has issued same book" ); >+ is( $reply->{pickup_location}, undef, "No reserve placed"); >+ > $schema->storage->txn_rollback; > }; > >@@ -716,7 +732,7 @@ subtest 'GetPatronInfo paginated loans' => sub { > }); > my $module = new Test::MockModule('C4::Context'); > $module->mock('userenv', sub { { branch => $library->branchcode } }); >- my $date_due = DateTime->now->add(weeks => 2); >+ my $date_due = Koha::DateUtils::dt_from_string()->add(weeks => 2); > my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due); > my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due ); > my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due); >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index e9f1de6f86..2059ba9ea9 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 62; >+use Test::More tests => 63; > use Test::MockModule; > use Test::Warn; > >@@ -1035,6 +1035,44 @@ subtest 'MoveReserve additional test' => sub { > > }; > >+subtest 'AllowHoldOnPatronPossession test' => sub { >+ >+ plan tests => 4; >+ >+ # Create the items and patrons we need >+ my $biblio = $builder->build_sample_biblio(); >+ my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } }); >+ my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber,notforloan => 0, itype => $itype->itemtype }); >+ my $patron = $builder->build_object({ class => "Koha::Patrons", >+ value => { branchcode => $item->homebranch }}); >+ >+ C4::Circulation::AddIssue($patron->unblessed, >+ $item->barcode); >+ t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 0); >+ >+ is(C4::Reserves::CanBookBeReserved($patron->borrowernumber, >+ $item->biblionumber)->{status}, >+ 'itemAlreadyOnLoan', >+ 'Patron cannot place hold on a book loaned to itself'); >+ >+ is(C4::Reserves::CanItemBeReserved($patron->borrowernumber, >+ $item->itemnumber)->{status}, >+ 'itemAlreadyOnLoan', >+ 'Patron cannot place hold on an item loaned to itself'); >+ >+ t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 1); >+ >+ is(C4::Reserves::CanBookBeReserved($patron->borrowernumber, >+ $item->biblionumber)->{status}, >+ 'OK', >+ 'Patron can place hold on a book loaned to itself'); >+ >+ is(C4::Reserves::CanItemBeReserved($patron->borrowernumber, >+ $item->itemnumber)->{status}, >+ 'OK', >+ 'Patron can place hold on an item loaned to itself'); >+}; >+ > sub count_hold_print_messages { > my $message_count = $dbh->selectall_arrayref(q{ > SELECT COUNT(*) >-- >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 22806
:
89039
|
89724
|
91784
|
94388
|
94389
|
97947
|
99881
|
99882
|
99883
|
99884
|
99885
|
100091
|
100092
|
100093
|
100173
|
100174
|
100175
|
106564
|
106778
|
106779
|
106780
|
107760
|
107806
|
110100
|
110101
|
110102
|
110973
|
110974
|
110975
|
110976
|
111771
|
111772
|
111773
|
111774
|
112824