From 1587a69e1e7b9899ffca50f12b923bf9ff213173 Mon Sep 17 00:00:00 2001 From: Kenza Zaki Date: Thu, 25 Jul 2013 10:18:11 +0200 Subject: [PATCH] [PASSED QA] ModBookseller needs more explicit return values in C4::Bookseller.pm Before, ModBookseller always returns undef. This patch modifies it in order to be more explicit. Now it returns : 1 -> If a modification has been done 0E0 -> If the given id doesn't exist undef -> If no id given It also fix one of the tests which didn't pass before in t/db_dependent/Bookseller.t To Test: prove t/db_dependent/Bookseller.t Bookseller.t .. 1/54 [Some warnings about uninitialized values] t/db_dependent/Bookseller.t .. ok All tests successful. Files=1, Tests=54, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.46 cusr 0.04 csys = 0.53 CPU) Result: PASS http://bugs.koha-community.org/show_bug.cgi?id=10640 Signed-off-by: Srdjan Signed-off-by: Katrin Fischer Change is logical and passes new and old tests. Fixed the author line to have Kenza's correct email address. --- C4/Bookseller.pm | 4 ++-- t/db_dependent/Bookseller.t | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm index 3e1454f..97500f0 100644 --- a/C4/Bookseller.pm +++ b/C4/Bookseller.pm @@ -226,6 +226,7 @@ C<&ModBookseller> with the result. sub ModBookseller { my ($data) = @_; my $dbh = C4::Context->dbh; + return unless $data->{'id'}; my $query = 'UPDATE aqbooksellers SET name=?,address1=?,address2=?,address3=?,address4=?, postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?, @@ -235,7 +236,7 @@ sub ModBookseller { discount=?,notes=?,gstrate=?,deliverytime=? WHERE id=?'; my $sth = $dbh->prepare($query); - $sth->execute( + return $sth->execute( $data->{'name'}, $data->{'address1'}, $data->{'address2'}, $data->{'address3'}, $data->{'address4'}, $data->{'postal'}, @@ -253,7 +254,6 @@ sub ModBookseller { $data->{deliverytime}, $data->{'id'} ); - return; } =head2 DelBookseller diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t index 71307f1..df83fa0 100644 --- a/t/db_dependent/Bookseller.t +++ b/t/db_dependent/Bookseller.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 53; +use Test::More tests => 54; use C4::Context; use Koha::DateUtils; use DateTime::Duration; @@ -248,13 +248,11 @@ $sample_supplier2 = { deliverytime => 2, }; -#FIXME : ModBookseller always returns undef, even if the id isn't given -#or doesn't exist my $modif1 = C4::Bookseller::ModBookseller(); is( $modif1, undef, "ModBookseller returns undef if no params given - Nothing happened" ); $modif1 = C4::Bookseller::ModBookseller($sample_supplier2); -#is( $modif1, 1, "ModBookseller modifies only the supplier2" ); +is( $modif1, 1, "ModBookseller modifies only the supplier2" ); is( scalar( C4::Bookseller::GetBookSeller('') ), $count + 2, "Supplier2 has been modified - Nothing added" ); -- 1.7.9.5