Bugzilla – Attachment 19927 Details for
Bug 10630
DelBookseller's return value needs to be more explicit in C4::Bookseller.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10630: DelBookseller's always returns undef in C4::Bookseller.pm
Bug-10630-DelBooksellers-always-returns-undef-in-C.patch (text/plain), 4.58 KB, created by
kenza
on 2013-07-24 13:42:40 UTC
(
hide
)
Description:
Bug 10630: DelBookseller's always returns undef in C4::Bookseller.pm
Filename:
MIME Type:
Creator:
kenza
Created:
2013-07-24 13:42:40 UTC
Size:
4.58 KB
patch
obsolete
>From e6b4f92d15b8acf2fa4f63441edf6a7868398223 Mon Sep 17 00:00:00 2001 >From: root <root@kenza-VirtualBox> >Date: Wed, 24 Jul 2013 15:30:09 +0200 >Subject: [PATCH] Bug 10630: DelBookseller's always returns undef in > C4::Bookseller.pm > >This patch makes DelBookseller returns the number of supplier it has deleted >or undef if nothing has been deleted. >It also adds some regression tests. > >To test: >prove t/db_dependent/Bookseller.t >t/db_dependent/Bookseller.t .. ok >All tests successful. >Files=1, Tests=7, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.40 cusr 0.03 csys = 0.45 CPU) >Result: PASS >--- > C4/Bookseller.pm | 3 +- > t/db_dependent/Bookseller.t | 114 +++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 115 insertions(+), 2 deletions(-) > create mode 100644 t/db_dependent/Bookseller.t > >diff --git a/C4/Bookseller.pm b/C4/Bookseller.pm >index 3e1454f..c53919f 100644 >--- a/C4/Bookseller.pm >+++ b/C4/Bookseller.pm >@@ -269,8 +269,7 @@ sub DelBookseller { > my $id = shift; > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare('DELETE FROM aqbooksellers WHERE id=?'); >- $sth->execute($id); >- return; >+ return $sth->execute($id); > } > > 1; >diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t >new file mode 100644 >index 0000000..8281481 >--- /dev/null >+++ b/t/db_dependent/Bookseller.t >@@ -0,0 +1,114 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 7; >+use C4::Context; >+use Koha::DateUtils; >+use DateTime::Duration; >+use C4::Acquisition; >+use C4::Serials; >+use C4::Budgets; >+use C4::Biblio; >+ >+BEGIN { >+ use_ok('C4::Bookseller'); >+} >+ >+can_ok( >+ >+ 'C4::Bookseller', qw( >+ AddBookseller >+ DelBookseller >+ GetBookSeller >+ GetBookSellerFromId >+ GetBooksellersWithLateOrders >+ ModBookseller ) >+); >+ >+#Start transaction >+my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+$dbh->{AutoCommit} = 0; >+ >+#Start tests >+$dbh->do(q|DELETE FROM aqorders|); >+$dbh->do(q|DELETE FROM aqbasket|); >+$dbh->do(q|DELETE FROM aqbooksellers|); >+ >+#Test AddBookseller >+my $count = scalar( C4::Bookseller::GetBookSeller('') ); >+my $sample_supplier1 = { >+ name => 'Name1', >+ address1 => 'address1_1', >+ address2 => 'address1-2', >+ address3 => 'address1_2', >+ address4 => 'address1_2', >+ postal => 'postal1', >+ phone => 'phone1', >+ accountnumber => 'accountnumber1', >+ fax => 'fax1', >+ url => 'url1', >+ contact => 'contact1', >+ contpos => 'contpos1', >+ contphone => 'contphone1', >+ contfax => 'contefax1', >+ contaltphone => 'contaltphone1', >+ contemail => 'contemail1', >+ contnotes => 'contnotes1', >+ active => 1, >+ gstreg => 1, >+ listincgst => 1, >+ invoiceincgst => 1, >+ gstrate => '1.0000', >+ discount => '1.0000', >+ notes => 'notes1', >+ deliverytime => undef >+}; >+my $sample_supplier2 = { >+ name => 'Name2', >+ address1 => 'address1_2', >+ address2 => 'address2-2', >+ address3 => 'address3_2', >+ address4 => 'address4_2', >+ postal => 'postal2', >+ phone => 'phone2', >+ accountnumber => 'accountnumber2', >+ fax => 'fax2', >+ url => 'url2', >+ contact => 'contact2', >+ contpos => 'contpos2', >+ contphone => 'contphone2', >+ contfax => 'contefax2', >+ contaltphone => 'contaltphone2', >+ contemail => 'contemail2', >+ contnotes => 'contnotes2', >+ active => 1, >+ gstreg => 1, >+ listincgst => 1, >+ invoiceincgst => 1, >+ gstrate => '2.0000', >+ discount => '2.0000', >+ notes => 'notes2', >+ deliverytime => 2, >+}; >+ >+my $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1); >+my $id_supplier2 = C4::Bookseller::AddBookseller($sample_supplier2); >+ >+#my $id_bookseller3 = C4::Bookseller::AddBookseller();# NOTE : Doesn't work because the field name cannot be null >+ >+like( $id_supplier1, '/^\d+$/', "AddBookseller for supplier1 return an id" ); >+like( $id_supplier2, '/^\d+$/', "AddBookseller for supplier2 return an id" ); >+is( scalar( C4::Bookseller::GetBookSeller('') ), >+ $count + 2, "Supplier1 and Supplier2 have been added" ); >+ >+#Test DelBookseller >+my $del = C4::Bookseller::DelBookseller($id_supplier1); >+is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " ); >+is( C4::Bookseller::GetBookSellerFromId($id_supplier1), >+ undef, "Supplier1 has been deleted - id_supplier1 doesnt exist anymore" ); >+ >+#End transaction >+$dbh->rollback; >+ >-- >1.7.9.5
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 10630
:
19927
|
19937
|
20203
|
20586