Bugzilla – Attachment 114851 Details for
Bug 27131
Move code from circ/pendingreserves.pl to modules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27131: Add tests for get_items_that_can_fill
Bug-27131-Add-tests-for-getitemsthatcanfill.patch (text/plain), 3.51 KB, created by
Jonathan Druart
on 2021-01-05 08:33:20 UTC
(
hide
)
Description:
Bug 27131: Add tests for get_items_that_can_fill
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-05 08:33:20 UTC
Size:
3.51 KB
patch
obsolete
>From 76e22434f7065df9581be0b284e7d4c09bc8f3e6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 5 Jan 2021 09:29:07 +0100 >Subject: [PATCH] Bug 27131: Add tests for get_items_that_can_fill > >--- > t/db_dependent/Koha/Holds.t | 69 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 68 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index 538e7119de..84c26badb7 100755 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -19,9 +19,10 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::Warn; > >+use C4::Circulation; > use C4::Reserves; > use Koha::AuthorisedValueCategory; > use Koha::Database; >@@ -408,6 +409,72 @@ subtest 'Desks' => sub { > > }; > >+subtest 'get_items_that_can_fill' => sub { >+ plan tests => 1; >+ >+ my $biblio = $builder->build_sample_biblio; >+ my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $item_3 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ) >+ ; # onloan >+ my $item_4 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ) >+ ; # in transfer >+ my $item_5 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $lost = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 1 } ); >+ my $withdrawn = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 1 } ); >+ my $notforloan = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } ); >+ >+ my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron_3 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ t::lib::Mocks::mock_userenv( { patron => $patron_1 } ); >+ >+ my $reserve_id_1 = C4::Reserves::AddReserve( >+ { >+ borrowernumber => $patron_1->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => 1, >+ itemnumber => $item_1->itemnumber, >+ } >+ ); >+ >+ my $waiting_reserve_id = C4::Reserves::AddReserve( >+ { >+ borrowernumber => $patron_2->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => 0, >+ found => 'W', >+ itemnumber => $item_1->itemnumber, >+ } >+ ); >+ >+ # item 3 is on loan >+ AddIssue( $patron_3->unblessed, $item_3->barcode ); >+ >+ # item 4 is in transfer >+ my $from = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $to = $builder->build_object( { class => 'Koha::Libraries' } ); >+ Koha::Item::Transfer->new( >+ { >+ itemnumber => $item_4->itemnumber, >+ datearrived => undef, >+ frombranch => $from->branchcode, >+ tobranch => $to->branchcode >+ } >+ )->store; >+ >+ my $holds = Koha::Holds->search( >+ { >+ reserve_id => [ $reserve_id_1, $reserve_id_2, $waiting_reserve_id, ] >+ } >+ ); >+ >+ my @items = $holds->get_items_that_can_fill; >+ is_deeply( [ map { $_->itemnumber } @items ], >+ [ $item_2->itemnumber, $item_5->itemnumber ], 'Only item 1 and 5 are available for filling the hold' ); >+}; >+ > $schema->storage->txn_rollback; > > 1; >-- >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 27131
:
114085
|
114851
|
114852
|
116969
|
116970
|
116971
|
116972
|
116973
|
116977