View | Details | Raw Unified | Return to bug 8007
Collapse All | Expand All

(-)a/t/db_dependent/Borrower_Discharge.t (-1 / +59 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl;
2
3
use Modern::Perl;
4
use Test::More;
5
use MARC::Record;
6
7
use C4::Biblio qw( AddBiblio );
8
use C4::Circulation qw( AddIssue AddReturn );
9
use C4::Context;
10
use C4::Items qw( AddItem );
11
use C4::Members qw( AddMember GetMember );
12
13
use Koha::Borrower::Discharge;
14
15
my $dbh = C4::Context->dbh;
16
$dbh->{AutoCommit} = 0;
17
$dbh->{RaiseError} = 1;
18
19
$dbh->do(q|DELETE FROM discharges|);
20
21
C4::Context->_new_userenv('xxx');
22
C4::Context::set_userenv(0, 0, 0, 'firstname', 'surname', 'CPL', 'CPL', '', '', '');
23
24
my $borrowernumber = AddMember(
25
    cardnumber => 'UTCARD1',
26
    firstname => 'my firstname',
27
    surname => 'my surname',
28
    categorycode => 'S',
29
    branchcode => 'CPL',
30
);
31
my $borrower = GetMember( borrowernumber => $borrowernumber );
32
33
# Discharge not possible with issues
34
my ( $biblionumber ) = AddBiblio( MARC::Record->new, '');
35
my $barcode = 'BARCODE42';
36
my ( undef, undef, $itemnumber ) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL', barcode => $barcode }, $biblionumber);
37
AddIssue( $borrower, $barcode );
38
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernumber }), 0, 'A patron with issues cannot be discharged' );
39
40
is( Koha::Borrower::Discharge::request({ borrowernumber => $borrowernumber }), undef, 'No request done if patron has issues' );
41
is( Koha::Borrower::Discharge::discharge({ borrowernumber => $borrowernumber }), undef, 'No discharge done if patron has issues' );
42
is_deeply( Koha::Borrower::Discharge::get_pendings(), [], 'There is no pending discharge request' );
43
44
AddReturn( $barcode );
45
46
# Discharge possible without issue
47
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernumber }), 1, 'A patron without issues can be discharged' );
48
49
# FIXME
50
# At this point, there is a problem with the AutoCommit off
51
# The transaction is bloked into DBIx::Class::Storage::DBI::_dbh_execute
52
# line my $rv = $sth->execute();
53
# We are using 2 connections and the one used by Koha::Schema has the AutoCommit set to 1
54
# Even if we switch off this flag, the connection will be blocked.
55
# The error is:
56
# 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
57
#is( Koha::Service::Borrower::Discharge::request({ borrowernumber => $borrowernumber }), 1, 'Discharge request sent' );
58
59
done_testing;

Return to bug 8007