@@ -, +, @@ GetAllPendingTransfers functions to ease testing. --- C4/Circulation.pm | 38 ++++++++++++++++++++++++++++++++ t/db_dependent/Circulation_transfers.t | 9 +++++++- 2 files changed, 46 insertions(+), 1 deletion(-) --- a/C4/Circulation.pm +++ a/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); --- a/t/db_dependent/Circulation_transfers.t +++ a/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( --