Bugzilla – Attachment 39061 Details for
Bug 14188
branchtransfers GetAllTransfers and GetAllPendingTransfers functions to ease testing.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14188 - branchtransfers GetAllTransfers and GetAllPendingTransfers functions to ease testing.
Bug-14188---branchtransfers-GetAllTransfers-and-Ge.patch (text/plain), 2.98 KB, created by
Olli-Antti Kivilahti
on 2015-05-12 08:44:05 UTC
(
hide
)
Description:
Bug 14188 - branchtransfers GetAllTransfers and GetAllPendingTransfers functions to ease testing.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-05-12 08:44:05 UTC
Size:
2.98 KB
patch
obsolete
>From 8c047b7d47e0db839bc51b82014cfb30a5029db4 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 12 May 2015 11:40:28 +0300 >Subject: [PATCH] Bug 14188 - branchtransfers GetAllTransfers and > GetAllPendingTransfers functions to ease testing. > >Because there is no nice way of getting all branchtransfers and putting SQL into >tests is VERY VERY BAD, introducing these branchtransfer API calls to >conveniently get all transfers data nicely. > >Unit tests included. > >TEST PLAN: >Run t/db_dependent/Circulation_transfers.t >--- > C4/Circulation.pm | 38 ++++++++++++++++++++++++++++++++ > t/db_dependent/Circulation_transfers.t | 9 +++++++- > 2 files changed, 46 insertions(+), 1 deletion(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c6ecd62..e01a6e9 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3143,6 +3143,44 @@ sub GetTransfersFromTo { > return (@gettransfers); > } > >+=head2 GetAllPendingTransfers >+ >+ C4::Circulation::GetAllPendingTransfers(); >+ >+@RETURNS Reference to ARRAY of HASHes, >+ All rows in the koha.branchtransfers-table that have not arrived yet. >+ Warning, the amount of rows returned in production can be in the thousands. >+=cut >+ >+sub GetAllPendingTransfers { >+ my $dbh = C4::Context->dbh; >+ >+ my $query = 'SELECT * FROM branchtransfers WHERE datearrived IS NULL'; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(); >+ my $pendingTransfers = $sth->fetchall_arrayref({}); >+ return $pendingTransfers; >+} >+ >+=head2 GetAllTransfers >+ >+ C4::Circulation::GetAllTransfers(); >+ >+@RETURNS Reference to ARRAY of HASHes, >+ All rows in the koha.branchtransfers-table. >+ Warning, the amount of rows returned in production can be in the millions. >+=cut >+ >+sub GetAllTransfers { >+ my $dbh = C4::Context->dbh; >+ >+ my $query = 'SELECT * FROM branchtransfers'; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(); >+ my $transfers = $sth->fetchall_arrayref({}); >+ return $transfers; >+} >+ > =head2 DeleteTransfer > > &DeleteTransfer($itemnumber); >diff --git a/t/db_dependent/Circulation_transfers.t b/t/db_dependent/Circulation_transfers.t >index 0c92222..f107854 100644 >--- a/t/db_dependent/Circulation_transfers.t >+++ b/t/db_dependent/Circulation_transfers.t >@@ -9,7 +9,7 @@ use C4::Circulation; > use Koha::DateUtils; > use DateTime::Duration; > >-use Test::More tests => 22; >+use Test::More tests => 24; > use Test::Deep; > > BEGIN { >@@ -121,6 +121,13 @@ ModItemTransfer( > ); > > #Begin Tests >+#Test GetAllTransfers() >+my $allTransfers = C4::Circulation::GetAllTransfers(); >+ok(($allTransfers && scalar(@$allTransfers) == 2), "GetAllTransfers() returns all transfers :)"); >+#Test GetAllPendingTransfers() >+my $pendingTransfers = C4::Circulation::GetAllPendingTransfers(); >+ok(($pendingTransfers && scalar(@$pendingTransfers) == 2), "GetAllPendingTransfers() returns all pending transfers :)"); >+ > #Test CreateBranchTransferLimit > is( > CreateBranchTransferLimit( >-- >1.7.9.5
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 14188
:
39061
|
40076