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

(-)a/t/db_dependent/Circulation_issue.t (-9 / +18 lines)
Lines 25-32 use C4::Branch; Link Here
25
use C4::Circulation;
25
use C4::Circulation;
26
use C4::Items;
26
use C4::Items;
27
use C4::Context;
27
use C4::Context;
28
use C4::Reserves;
28
29
29
use Test::More tests => 30;
30
use Test::More tests => 32;
30
31
31
BEGIN {
32
BEGIN {
32
    use_ok('C4::Circulation');
33
    use_ok('C4::Circulation');
Lines 149-157 $record->append_fields( Link Here
149
    MARC::Field->new( '952', '0', '0', a => $samplebranch1->{branchcode} ) );
150
    MARC::Field->new( '952', '0', '0', a => $samplebranch1->{branchcode} ) );
150
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' );
151
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' );
151
152
153
my $barcode_1 = 'barcode_1';
154
my $barcode_2 = 'barcode_2';
152
my @sampleitem1 = C4::Items::AddItem(
155
my @sampleitem1 = C4::Items::AddItem(
153
    {
156
    {
154
        barcode        => 'barcode_1',
157
        barcode        => $barcode_1,
155
        itemcallnumber => 'callnumber1',
158
        itemcallnumber => 'callnumber1',
156
        homebranch     => $samplebranch1->{branchcode},
159
        homebranch     => $samplebranch1->{branchcode},
157
        holdingbranch  => $samplebranch1->{branchcode},
160
        holdingbranch  => $samplebranch1->{branchcode},
Lines 163-169 my @sampleitem1 = C4::Items::AddItem( Link Here
163
my $item_id1    = $sampleitem1[2];
166
my $item_id1    = $sampleitem1[2];
164
my @sampleitem2 = C4::Items::AddItem(
167
my @sampleitem2 = C4::Items::AddItem(
165
    {
168
    {
166
        barcode        => 'barcode_2',
169
        barcode        => $barcode_2,
167
        itemcallnumber => 'callnumber2',
170
        itemcallnumber => 'callnumber2',
168
        homebranch     => $samplebranch2->{branchcode},
171
        homebranch     => $samplebranch2->{branchcode},
169
        holdingbranch  => $samplebranch2->{branchcode},
172
        holdingbranch  => $samplebranch2->{branchcode},
Lines 209-215 my $sth = $dbh->prepare($query); Link Here
209
$sth->execute;
212
$sth->execute;
210
my $countissue = $sth -> fetchrow_array;
213
my $countissue = $sth -> fetchrow_array;
211
is ($countissue ,0, "there is no issue");
214
is ($countissue ,0, "there is no issue");
212
my $issue1 = C4::Circulation::AddIssue( $borrower_1, 'barcode_1', $daysago10,0, $today, '' );
215
my $issue1 = C4::Circulation::AddIssue( $borrower_1, $barcode_1, $daysago10,0, $today, '' );
213
is( ref $issue1, 'Koha::Schema::Result::Issue',
216
is( ref $issue1, 'Koha::Schema::Result::Issue',
214
       'AddIssue returns a Koha::Schema::Result::Issue object' );
217
       'AddIssue returns a Koha::Schema::Result::Issue object' );
215
my $datedue1 = dt_from_string( $issue1->date_due() );
218
my $datedue1 = dt_from_string( $issue1->date_due() );
Lines 271-277 my $openissue = GetOpenIssue($borrower_id1, $item_id1); Link Here
271
274
272
my @renewcount;
275
my @renewcount;
273
#Test GetRenewCount
276
#Test GetRenewCount
274
my $issue3 = C4::Circulation::AddIssue( $borrower_1, 'barcode_1' );
277
my $issue3 = C4::Circulation::AddIssue( $borrower_1, $barcode_1 );
275
#Without anything in DB
278
#Without anything in DB
276
@renewcount = C4::Circulation::GetRenewCount();
279
@renewcount = C4::Circulation::GetRenewCount();
277
is_deeply(
280
is_deeply(
Lines 350-362 is_deeply( Link Here
350
);
353
);
351
354
352
$dbh->do("DELETE FROM old_issues");
355
$dbh->do("DELETE FROM old_issues");
353
AddReturn('barcode_1');
356
AddReturn($barcode_1);
354
my $return = $dbh->selectrow_hashref("SELECT DATE(returndate) AS return_date, CURRENT_DATE() AS today FROM old_issues LIMIT 1" );
357
my $return = $dbh->selectrow_hashref("SELECT DATE(returndate) AS return_date, CURRENT_DATE() AS today FROM old_issues LIMIT 1" );
355
ok( $return->{return_date} eq $return->{today}, "Item returned with no return date specified has todays date" );
358
ok( $return->{return_date} eq $return->{today}, "Item returned with no return date specified has todays date" );
356
359
357
$dbh->do("DELETE FROM old_issues");
360
$dbh->do("DELETE FROM old_issues");
358
C4::Circulation::AddIssue( $borrower_1, 'barcode_1', $daysago10, 0, $today );
361
C4::Circulation::AddIssue( $borrower_1, $barcode_1, $daysago10, 0, $today );
359
AddReturn('barcode_1', undef, undef, undef, '2014-04-01 23:42');
362
AddReturn($barcode_1, undef, undef, undef, '2014-04-01 23:42');
360
$return = $dbh->selectrow_hashref("SELECT * FROM old_issues LIMIT 1" );
363
$return = $dbh->selectrow_hashref("SELECT * FROM old_issues LIMIT 1" );
361
ok( $return->{returndate} eq '2014-04-01 23:42:00', "Item returned with a return date of '2014-04-01 23:42' has that return date" );
364
ok( $return->{returndate} eq '2014-04-01 23:42:00', "Item returned with a return date of '2014-04-01 23:42' has that return date" );
362
365
Lines 386-391 AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); Link Here
386
$item = GetItem( $itemnumber );
389
$item = GetItem( $itemnumber );
387
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
390
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
388
391
392
# Bug 14640 - Cancel the hold on checking out if asked
393
my $reserve_id = AddReserve('CPL', $borrower_id1, $biblionumber,
394
    undef,  1, undef, undef, "a note", "a title", undef, '');
395
ok( $reserve_id, 'The reserve should have been inserted' );
396
AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' );
397
my $reserve = GetReserve( $reserve_id );
398
is( $reserve, undef, 'The reserve should have been correctly cancelled' );
389
399
390
#End transaction
400
#End transaction
391
$dbh->rollback;
401
$dbh->rollback;
392
- 

Return to bug 14640