Bugzilla – Attachment 34672 Details for
Bug 8007
Discharge management
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8007: Discharge - Add unit tests
Bug-8007-Discharge---Add-unit-tests.patch (text/plain), 3.14 KB, created by
Jonathan Druart
on 2014-12-24 11:07:15 UTC
(
hide
)
Description:
Bug 8007: Discharge - Add unit tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-12-24 11:07:15 UTC
Size:
3.14 KB
patch
obsolete
>From 6365a7c6f274d8c9a429d8e560ce90a3bcf67021 Mon Sep 17 00:00:00 2001 >From: Yohann Dufour <dufour.yohann@gmail.com> >Date: Mon, 4 Aug 2014 16:09:53 +0200 >Subject: [PATCH] Bug 8007: Discharge - Add unit tests > >--- > t/db_dependent/Borrower_Discharge.t | 59 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 59 insertions(+) > create mode 100644 t/db_dependent/Borrower_Discharge.t > >diff --git a/t/db_dependent/Borrower_Discharge.t b/t/db_dependent/Borrower_Discharge.t >new file mode 100644 >index 0000000..7d22b0b >--- /dev/null >+++ b/t/db_dependent/Borrower_Discharge.t >@@ -0,0 +1,59 @@ >+#!/usr/bin/perl; >+ >+use Modern::Perl; >+use Test::More; >+use MARC::Record; >+ >+use C4::Biblio qw( AddBiblio ); >+use C4::Circulation qw( AddIssue AddReturn ); >+use C4::Context; >+use C4::Items qw( AddItem ); >+use C4::Members qw( AddMember GetMember ); >+ >+use Koha::Borrower::Discharge; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do(q|DELETE FROM discharges|); >+ >+C4::Context->_new_userenv('xxx'); >+C4::Context::set_userenv(0, 0, 0, 'firstname', 'surname', 'CPL', 'CPL', '', '', ''); >+ >+my $borrowernumber = AddMember( >+ cardnumber => 'UTCARD1', >+ firstname => 'my firstname', >+ surname => 'my surname', >+ categorycode => 'S', >+ branchcode => 'CPL', >+); >+my $borrower = GetMember( borrowernumber => $borrowernumber ); >+ >+# Discharge not possible with issues >+my ( $biblionumber ) = AddBiblio( MARC::Record->new, ''); >+my $barcode = 'BARCODE42'; >+my ( undef, undef, $itemnumber ) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL', barcode => $barcode }, $biblionumber); >+AddIssue( $borrower, $barcode ); >+is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernumber }), 0, 'A patron with issues cannot be discharged' ); >+ >+is( Koha::Borrower::Discharge::request({ borrowernumber => $borrowernumber }), undef, 'No request done if patron has issues' ); >+is( Koha::Borrower::Discharge::discharge({ borrowernumber => $borrowernumber }), undef, 'No discharge done if patron has issues' ); >+is_deeply( Koha::Borrower::Discharge::get_pendings(), [], 'There is no pending discharge request' ); >+ >+AddReturn( $barcode ); >+ >+# Discharge possible without issue >+is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernumber }), 1, 'A patron without issues can be discharged' ); >+ >+# FIXME >+# At this point, there is a problem with the AutoCommit off >+# The transaction is bloked into DBIx::Class::Storage::DBI::_dbh_execute >+# line my $rv = $sth->execute(); >+# We are using 2 connections and the one used by Koha::Schema has the AutoCommit set to 1 >+# Even if we switch off this flag, the connection will be blocked. >+# The error is: >+# DBIx::Class::ResultSet::create(): DBI Exception: DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction [for Statement "INSERT INTO discharges ( borrower, needed, validated) VALUES ( ?, ?, ? )" with ParamValues: 0='121', 1='2014-01-08T16:38:29', 2=undef] at /home/koha/src/Koha/DataObject/Discharge.pm line 33 >+#is( Koha::Service::Borrower::Discharge::request({ borrowernumber => $borrowernumber }), 1, 'Discharge request sent' ); >+ >+done_testing; >-- >2.1.0
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 8007
:
14490
|
16622
|
16935
|
17484
|
17485
|
21394
|
21395
|
21396
|
21660
|
21674
|
21675
|
21676
|
21677
|
21678
|
24023
|
24024
|
24025
|
24026
|
24027
|
30531
|
30532
|
30533
|
30534
|
30535
|
31007
|
34034
|
34035
|
34036
|
34037
|
34038
|
34039
|
34668
|
34669
|
34670
|
34671
|
34672
|
34673
|
34674
|
34675
|
36180
|
36181
|
36182
|
36183
|
36184
|
36185
|
36186
|
36187
|
36394
|
36395
|
36396
|
36397
|
36398
|
36399
|
36400
|
36401
|
37029
|
37030
|
37031
|
37032
|
37033
|
37034
|
37035
|
37036
|
37037
|
38596
|
38597