Bugzilla – Attachment 24277 Details for
Bug 11550
Add a couple of unit tests for C4::Acq::GetOrder
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11550: GetOrder always returns a non empty hashref
Bug-11550-GetOrder-always-returns-a-non-empty-hash.patch (text/plain), 2.13 KB, created by
Jonathan Druart
on 2014-01-14 11:25:28 UTC
(
hide
)
Description:
Bug 11550: GetOrder always returns a non empty hashref
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-01-14 11:25:28 UTC
Size:
2.13 KB
patch
obsolete
>From d389f44404687862d28b5ed87da6f8f54987b709 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 14 Jan 2014 12:21:43 +0100 >Subject: [PATCH] Bug 11550: GetOrder always returns a non empty hashref > >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 | 5 ++++- > t/db_dependent/Acquisition.t | 7 ++++++- > 2 files changed, 10 insertions(+), 2 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 67ea46e..f7b1e28 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1110,6 +1110,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.*, >@@ -1147,7 +1149,8 @@ sub GetOrder { > my $sth= $dbh->prepare($query); > $sth->execute($ordernumber); > my $data = $sth->fetchrow_hashref; >- $data->{orderdate} = format_date( $data->{orderdate} ); >+ return unless $data; >+ $data->{orderdate} = format_date( $data->{orderdate} ); # FIXME Should be done in the templates > $sth->finish; > return $data; > } >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index 2585802..947e8d9 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 => 62; >+use Test::More tests => 64; > > BEGIN { > use_ok('C4::Acquisition'); >@@ -223,4 +223,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 return undef if a nonexistent ordernumber is given' ); >+ > $dbh->rollback; >-- >1.7.10.4
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 11550
:
24277
|
25686
|
25955
|
26124
|
26144
|
26145
|
26146