From 37582572821a3dee817489ae299cc10687fce28f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 Jan 2014 12:21:43 +0100 Subject: [PATCH] Bug 11550: Add UT for C4::Acquisition::GetOrder If GetOrder is called with a nonexistent ordernumber or without any ordernumber, it should return undef. Test plan: prove t/db_dependent/Acquisition.t --- C4/Acquisition.pm | 2 ++ t/db_dependent/Acquisition.t | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index b848c73..e2f1e8c 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1101,6 +1101,8 @@ C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d sub GetOrder { my ($ordernumber) = @_; + return unless $ordernumber; + my $dbh = C4::Context->dbh; my $query = qq{SELECT aqorders.*, diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index 1cb6d4b..4ba2198 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -8,7 +8,7 @@ use POSIX qw(strftime); use C4::Bookseller qw( GetBookSellerFromId ); -use Test::More tests => 63; +use Test::More tests => 65; BEGIN { use_ok('C4::Acquisition'); @@ -224,4 +224,9 @@ is($order3->{'quantityreceived'}, 2, 'Order not split up'); is($order3->{'quantity'}, 2, '2 items on order'); is($order3->{'budget_id'}, $budgetid2, 'Budget has changed'); +my $nonexistent_order = GetOrder(); +is( $nonexistent_order, undef, 'GetOrder returns undef if no ordernumber is given' ); +$nonexistent_order = GetOrder( 424242424242 ); +is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' ); + $dbh->rollback; -- 1.7.10.4