From be4fb1db9cc17d6d4f10ad8e633b5b87844d1472 Mon Sep 17 00:00:00 2001 From: Kenza Zaki Date: Thu, 25 Jul 2013 10:18:11 +0200 Subject: [PATCH] Bug 10640: give ModBookseller() an explicit return value. 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 fixes 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 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. Signed-off-by: Galen Charlton --- C4/Bookseller.pm | 4 ++-- t/db_dependent/Bookseller.t | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm index c53919f5e0..f56f4e3ad8 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 fdac9c2542..73e0588059 100644 --- a/t/db_dependent/Bookseller.t +++ b/t/db_dependent/Bookseller.t @@ -247,13 +247,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" ); -- 2.39.5