Bugzilla – Attachment 117576 Details for
Bug 25755
Add a Koha::Item->request_transfer method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25755: Add Unit tests for update to get_transfer
Bug-25755-Add-Unit-tests-for-update-to-gettransfer.patch (text/plain), 4.72 KB, created by
Jonathan Druart
on 2021-03-03 14:28:43 UTC
(
hide
)
Description:
Bug 25755: Add Unit tests for update to get_transfer
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-03 14:28:43 UTC
Size:
4.72 KB
patch
obsolete
>From 45451b9f2cc827559b46cdcbc8c0afe95e04b552 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 18 Sep 2020 14:56:23 +0100 >Subject: [PATCH] Bug 25755: Add Unit tests for update to get_transfer >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >We updated Koha::Item->get_transfer here to account for the new >daterequested field availability. It is now possible to set requested >without setting datesent simultaneiously.. as such we need to update >get_transfer to ensure we always return the right transfer (either the >one 'in transit' or the oldest request first. > >This patch update the unit tests to test for this. > >Signed-off-by: Kathleen Milne <kathleen.milne@cne-siar.gov.uk> >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > Koha/Item.pm | 2 -- > t/db_dependent/Koha/Items.t | 63 ++++++++++++++++++++++++++++++++----- > 2 files changed, 56 insertions(+), 9 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 76e9ef39b3..a31fc531bb 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -462,8 +462,6 @@ Note: Transfers are retrieved in a Modified FIFO (First In First Out) order > whereby the most recently sent, but not recieved, transfer will be returned > if it exists, otherwise the oldest unsatisfied transfer will be returned. > >-FIXME: Add Tests for FIFO functionality >- > =cut > > sub get_transfer { >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 980cd12bfe..26d6f72c99 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -1184,23 +1184,72 @@ subtest 'store' => sub { > }; > > subtest 'get_transfer' => sub { >- plan tests => 3; >+ plan tests => 6; > > my $transfer = $new_item_1->get_transfer(); > is( $transfer, undef, 'Koha::Item->get_transfer should return undef if the item is not in transit' ); > > my $library_to = $builder->build( { source => 'Branch' } ); > >- C4::Circulation::transferbook({ >- from_branch => $new_item_1->holdingbranch, >- to_branch => $library_to->{branchcode}, >- barcode => $new_item_1->barcode, >- }); >+ my $transfer_1 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $new_item_1->itemnumber, >+ frombranch => $new_item_1->holdingbranch, >+ tobranch => $library_to->{branchcode}, >+ reason => 'Manual', >+ datesent => undef, >+ datearrived => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); > > $transfer = $new_item_1->get_transfer(); > is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' ); > >- is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' ); >+ my $transfer_2 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $new_item_1->itemnumber, >+ frombranch => $new_item_1->holdingbranch, >+ tobranch => $library_to->{branchcode}, >+ reason => 'Manual', >+ datesent => undef, >+ datearrived => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); >+ >+ $transfer = $new_item_1->get_transfer(); >+ is( $transfer->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfer returns the oldest transfer request'); >+ >+ $transfer_2->datesent(\'NOW()')->store; >+ $transfer = $new_item_1->get_transfer(); >+ is( $transfer->branchtransfer_id, $transfer_2->branchtransfer_id, 'Koha::Item->get_transfer returns the in_transit transfer'); >+ >+ my $transfer_3 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $new_item_1->itemnumber, >+ frombranch => $new_item_1->holdingbranch, >+ tobranch => $library_to->{branchcode}, >+ reason => 'Manual', >+ datesent => undef, >+ datearrived => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); >+ >+ $transfer_2->datearrived(\'NOW()')->store; >+ $transfer = $new_item_1->get_transfer(); >+ is( $transfer->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfer returns the next queued transfer'); >+ is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer returns the right items transfer' ); > }; > > subtest 'holds' => sub { >-- >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 25755
:
105887
|
107240
|
107294
|
110273
|
110376
|
110392
|
110393
|
110394
|
110430
|
110466
|
110502
|
110503
|
110504
|
110505
|
110506
|
111142
|
111143
|
111144
|
111145
|
111146
|
116541
|
116542
|
116543
|
116544
|
116545
|
116546
|
117574
|
117575
| 117576 |
117577
|
117578
|
117579