Bugzilla – Attachment 110504 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 get_transfer
Bug-25755-Add-Unit-tests-for-update-gettransfer.patch (text/plain), 4.51 KB, created by
Katrin Fischer
on 2020-09-21 20:49:32 UTC
(
hide
)
Description:
Bug 25755: Add Unit tests for update get_transfer
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2020-09-21 20:49:32 UTC
Size:
4.51 KB
patch
obsolete
>From ef0dbb5fc53ab9796d92da60386d7658c04fadb2 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 get_transfer > >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: Katrin Fischer <katrin.fischer.83@web.de> >--- > 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 64aa7a34ab..474d5770bb 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 5cc3f3702e..978a257557 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -811,23 +811,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.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 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