Bugzilla – Attachment 20267 Details for
Bug 10710
UT : OfflineOperation's routines in C4/Circulation.t need unit tests.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10710 : OfflineOperation's routines in C4/Circulation.pm need unit tests.
Bug-10710--OfflineOperations-routines-in-C4Circula.patch (text/plain), 3.85 KB, created by
kenza
on 2013-08-12 12:24:57 UTC
(
hide
)
Description:
Bug 10710 : OfflineOperation's routines in C4/Circulation.pm need unit tests.
Filename:
MIME Type:
Creator:
kenza
Created:
2013-08-12 12:24:57 UTC
Size:
3.85 KB
patch
obsolete
>From 82eb39c91b7f21fc6f6e241fc64206f1550c4cd3 Mon Sep 17 00:00:00 2001 >From: Kenza Zaki <kenza.zaki@biblibre.com> >Date: Mon, 12 Aug 2013 14:16:46 +0200 >Subject: [PATCH] Bug 10710 : OfflineOperation's routines in C4/Circulation.pm > need unit tests. > >This patch test AddOfflineOperation,GetOfflineOperation and DeleteOfflineOperation in C4/Circulation.pm. >The tests are wrap in a transaction. > >Note: Currently, GetOfflineOperations is not tested because we cannot mock C4::Context->userenv in unit tests > >To test: >prove t/db_dependent/Circulation_OfflineOperation.t >t/db_dependent/Circulation_OfflineOperation.t .. ok >All tests successful. >Files=1, Tests=7, 19 wallclock secs ( 0.01 usr 0.01 sys + 0.33 cusr 0.02 csys = 0.37 CPU >--- > t/db_dependent/Circulation_OfflineOperation.t | 97 +++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) > create mode 100644 t/db_dependent/Circulation_OfflineOperation.t > >diff --git a/t/db_dependent/Circulation_OfflineOperation.t b/t/db_dependent/Circulation_OfflineOperation.t >new file mode 100644 >index 0000000..a6e9a95 >--- /dev/null >+++ b/t/db_dependent/Circulation_OfflineOperation.t >@@ -0,0 +1,97 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use C4::Branch; >+use C4::Circulation; >+ >+use Test::More tests => 7; >+ >+BEGIN { >+ use_ok('C4::Circulation'); >+} >+can_ok( >+ 'C4::Circulation', >+ qw( >+ AddOfflineOperation >+ GetOfflineOperation >+ GetOfflineOperations >+ DeleteOfflineOperation >+ ) >+); >+ >+#Start transaction >+my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+$dbh->{AutoCommit} = 0; >+ >+$dbh->do(q|DELETE FROM issues|); >+$dbh->do(q|DELETE FROM borrowers|); >+$dbh->do(q|DELETE FROM items|); >+$dbh->do(q|DELETE FROM branches|); >+$dbh->do(q|DELETE FROM pending_offline_operations|); >+ >+#Add branch >+my $samplebranch1 = { >+ add => 1, >+ branchcode => 'SAB1', >+ branchname => 'Sample Branch', >+ branchaddress1 => 'sample adr1', >+ branchaddress2 => 'sample adr2', >+ branchaddress3 => 'sample adr3', >+ branchzip => 'sample zip', >+ branchcity => 'sample city', >+ branchstate => 'sample state', >+ branchcountry => 'sample country', >+ branchphone => 'sample phone', >+ branchfax => 'sample fax', >+ branchemail => 'sample email', >+ branchurl => 'sample url', >+ branchip => 'sample ip', >+ branchprinter => undef, >+ opac_info => 'sample opac', >+}; >+ModBranch($samplebranch1); >+ >+#Begin Tests >+#Test AddOfflineOperation >+is( >+ AddOfflineOperation( >+ 'User1', $samplebranch1->{branchcode}, >+ 'null', 'Action1', 'CODE', 'Cardnumber1', 10 >+ ), >+ 'Added.', >+ "OfflineOperation has been added" >+); >+my $offline_id = >+ $dbh->last_insert_id( undef, undef, 'pending_offline_operations', undef ); >+ >+#Test GetOfflineOperations >+is_deeply( >+ GetOfflineOperation($offline_id), >+ { >+ operationid => $offline_id, >+ userid => 'User1', >+ branchcode => $samplebranch1->{branchcode}, >+ timestamp => "0000-00-00 00:00:00", >+ action => 'Action1', >+ barcode => 'CODE', >+ cardnumber => 'Cardnumber1', >+ amount => '10.000000' >+ }, >+ "GetOffline returns offlineoperation's informations" >+); >+is(GetOfflineOperation,undef,'GetOfflineOperation without parameters returns undef'); >+is(GetOfflineOperation(-1),undef,'GetOfflineOperation with wrong parameters returns undef'); >+ >+#Test GetOfflineOperations >+#TODO later: test GetOfflineOperations >+# Actually we cannot mock C4::Context->userenv in unit tests >+ >+#Test DeleteOfflineOperation >+is (DeleteOfflineOperation($offline_id),'Deleted.','Offlineoperation has been deleted'); >+#is (DeleteOfflineOperation, undef, 'DeleteOfflineOperation without id returns undef'); >+#is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME >+ >+#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 10710
:
20267
|
20349
|
20350
|
20598
|
20599