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

(-)a/t/db_dependent/Circulation.t (-3 / +23 lines)
Lines 278-284 Koha::CirculationRules->set_rules( Link Here
278
278
279
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
279
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
280
subtest "CanBookBeRenewed tests" => sub {
280
subtest "CanBookBeRenewed tests" => sub {
281
    plan tests => 87;
281
    plan tests => 89;
282
282
283
    C4::Context->set_preference('ItemsDeniedRenewal','');
283
    C4::Context->set_preference('ItemsDeniedRenewal','');
284
    # Generate test biblio
284
    # Generate test biblio
Lines 1158-1169 subtest "CanBookBeRenewed tests" => sub { Link Here
1158
    is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');
1158
    is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');
1159
1159
1160
    # Too many unseen renewals
1160
    # Too many unseen renewals
1161
    $dbh->do('UPDATE issuingrules SET unseen_renewals_allowed = 2, renewalsallowed = 10');
1161
    Koha::CirculationRules->set_rules(
1162
        {
1163
            categorycode => undef,
1164
            branchcode   => undef,
1165
            itemtype     => undef,
1166
            rules        => {
1167
                unseen_renewals_allowed => 2,
1168
                renewalsallowed => 10,
1169
            }
1170
        }
1171
    );
1162
    $dbh->do('UPDATE issues SET unseen_renewals = 2 where borrowernumber = ? AND itemnumber = ?', undef, ($renewing_borrowernumber, $item_1->itemnumber));
1172
    $dbh->do('UPDATE issues SET unseen_renewals = 2 where borrowernumber = ? AND itemnumber = ?', undef, ($renewing_borrowernumber, $item_1->itemnumber));
1163
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);
1173
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);
1164
    is( $renewokay, 0, 'Cannot renew, 0 unseen renewals allowed');
1174
    is( $renewokay, 0, 'Cannot renew, 0 unseen renewals allowed');
1165
    is( $error, 'too_unseen', 'Cannot renew, returned code is too_unseen');
1175
    is( $error, 'too_unseen', 'Cannot renew, returned code is too_unseen');
1166
    $dbh->do('UPDATE issuingrules SET norenewalbefore = NULL, renewalsallowed = 0');
1176
    Koha::CirculationRules->set_rules(
1177
        {
1178
            categorycode => undef,
1179
            branchcode   => undef,
1180
            itemtype     => undef,
1181
            rules        => {
1182
                norenewalbefore => undef,
1183
                renewalsallowed => 0,
1184
            }
1185
        }
1186
    );
1167
1187
1168
    # Test WhenLostForgiveFine and WhenLostChargeReplacementFee
1188
    # Test WhenLostForgiveFine and WhenLostChargeReplacementFee
1169
    t::lib::Mocks::mock_preference('WhenLostForgiveFine','1');
1189
    t::lib::Mocks::mock_preference('WhenLostForgiveFine','1');
(-)a/t/db_dependent/Circulation/issue.t (-24 / +41 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 46;
20
use Test::More tests => 48;
21
use DateTime::Duration;
21
use DateTime::Duration;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 297-316 subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub { Link Here
297
    }
297
    }
298
};
298
};
299
299
300
# Unseen rewnewals
301
t::lib::Mocks::mock_preference('UnseenRenewals', 1);
302
303
# Does an unseen renewal increment the issue's count
304
my ( $unseen_before ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3];
305
AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, $branchcode_1, undef, undef, 0 );
306
my ( $unseen_after ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3];
307
is( $unseen_after, $unseen_before + 1, 'unseen_renewals increments' );
308
309
# Does a seen renewal reset the unseen count
310
AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, $branchcode_1, undef, undef, 1 );
311
my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3];
312
is( $unseen_reset, 0, 'seen renewal resets the unseen count' );
313
314
#Test GetBiblioIssues
300
#Test GetBiblioIssues
315
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
301
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
316
302
Lines 327-345 my $issue3 = C4::Circulation::AddIssue( $borrower_1, $barcode_1 ); Link Here
327
@renewcount = C4::Circulation::GetRenewCount();
313
@renewcount = C4::Circulation::GetRenewCount();
328
is_deeply(
314
is_deeply(
329
    \@renewcount,
315
    \@renewcount,
330
    [ 0, 0, 0 ], # FIXME Need to be fixed, see FIXME in GetRenewCount
316
    [ 0, 0, 0, 0, 0, 0 ], # FIXME Need to be fixed, see FIXME in GetRenewCount
331
    "Without issuing rules and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0"
317
    "Without issuing rules and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0"
332
);
318
);
333
@renewcount = C4::Circulation::GetRenewCount(-1);
319
@renewcount = C4::Circulation::GetRenewCount(-1);
334
is_deeply(
320
is_deeply(
335
    \@renewcount,
321
    \@renewcount,
336
    [ 0, 0, 0 ], # FIXME Need to be fixed
322
    [ 0, 0, 0, 0, 0, 0 ], # FIXME Need to be fixed
337
    "Without issuing rules and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0"
323
    "Without issuing rules and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0"
338
);
324
);
339
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
325
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
340
is_deeply(
326
is_deeply(
341
    \@renewcount,
327
    \@renewcount,
342
    [ 2, 0, 0 ],
328
    [ 2, 0, 0, 0, 0, 0 ],
343
    "Without issuing rules and with a valid parameter, renewcount = 2, renewsallowed = undef, renewsleft = 0"
329
    "Without issuing rules and with a valid parameter, renewcount = 2, renewsallowed = undef, renewsleft = 0"
344
);
330
);
345
331
Lines 347-365 is_deeply( Link Here
347
@renewcount = C4::Circulation::GetRenewCount();
333
@renewcount = C4::Circulation::GetRenewCount();
348
is_deeply(
334
is_deeply(
349
    \@renewcount,
335
    \@renewcount,
350
    [ 0, 0, 0 ],
336
    [ 0, 0, 0, 0, 0, 0 ],
351
    "With issuing rules (renewal disallowed) and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0"
337
    "With issuing rules (renewal disallowed) and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0"
352
);
338
);
353
@renewcount = C4::Circulation::GetRenewCount(-1);
339
@renewcount = C4::Circulation::GetRenewCount(-1);
354
is_deeply(
340
is_deeply(
355
    \@renewcount,
341
    \@renewcount,
356
    [ 0, 0, 0 ],
342
    [ 0, 0, 0, 0, 0, 0 ],
357
    "With issuing rules (renewal disallowed) and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0"
343
    "With issuing rules (renewal disallowed) and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0"
358
);
344
);
359
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
345
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
360
is_deeply(
346
is_deeply(
361
    \@renewcount,
347
    \@renewcount,
362
    [ 2, 0, 0 ],
348
    [ 2, 0, 0, 0, 0, 0 ],
363
    "With issuing rules (renewal disallowed) and with a valid parameter, Getrenewcount returns renewcount = 2, renewsallowed = 0, renewsleft = 0"
349
    "With issuing rules (renewal disallowed) and with a valid parameter, Getrenewcount returns renewcount = 2, renewsallowed = 0, renewsleft = 0"
364
);
350
);
365
351
Lines 377-383 Koha::CirculationRules->set_rules( Link Here
377
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
363
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
378
is_deeply(
364
is_deeply(
379
    \@renewcount,
365
    \@renewcount,
380
    [ 2, 3, 1 ],
366
    [ 2, 3, 1, 0, 0, 0 ],
381
    "With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left"
367
    "With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left"
382
);
368
);
383
369
Lines 386-392 AddRenewal( $borrower_id1, $item_id1, $branchcode_1, Link Here
386
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
372
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
387
is_deeply(
373
is_deeply(
388
    \@renewcount,
374
    \@renewcount,
389
    [ 3, 3, 0 ],
375
    [ 3, 3, 0, 0, 0, 0 ],
390
    "With issuing rules (renewal allowed, 1 remaining) and with a valid parameter, Getrenewcount of item1 returns 0 renews left"
376
    "With issuing rules (renewal allowed, 1 remaining) and with a valid parameter, Getrenewcount of item1 returns 0 renews left"
391
);
377
);
392
378
Lines 504-508 AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' ); Link Here
504
my $hold = Koha::Holds->find( $reserve_id );
490
my $hold = Koha::Holds->find( $reserve_id );
505
is( $hold, undef, 'The reserve should have been correctly cancelled' );
491
is( $hold, undef, 'The reserve should have been correctly cancelled' );
506
492
493
# Unseen rewnewals
494
t::lib::Mocks::mock_preference('UnseenRenewals', 1);
495
# Add a default circ rule: 3 unseen renewals allowed
496
Koha::CirculationRules->set_rules(
497
    {
498
        categorycode => undef,
499
        itemtype     => undef,
500
        branchcode   => undef,
501
        rules        => {
502
            renewalsallowed => 10,
503
            unseen_renewals_allowed => 3
504
        }
505
    }
506
);
507
508
my $unseen_library = $builder->build_object( { class => 'Koha::Libraries' } );
509
my $unseen_patron  = $builder->build_object( { class => 'Koha::Patrons' } );
510
my $unseen_item = $builder->build_sample_item(
511
    { library => $unseen_library->branchcode, itype => $itemtype } );
512
my $unseen_issue = C4::Circulation::AddIssue( $unseen_patron->unblessed, $unseen_item->barcode );
513
514
# Does an unseen renewal increment the issue's count
515
my ( $unseen_before ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3];
516
AddRenewal( $unseen_patron->borrowernumber, $unseen_item->itemnumber, $branchcode_1, undef, undef, undef, 0 );
517
my ( $unseen_after ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3];
518
is( $unseen_after, $unseen_before + 1, 'unseen_renewals increments' );
519
520
# Does a seen renewal reset the unseen count
521
AddRenewal( $unseen_patron->borrowernumber, $unseen_item->itemnumber, $branchcode_1, undef, undef, undef, 1 );
522
my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3];
523
is( $unseen_reset, 0, 'seen renewal resets the unseen count' );
524
507
#End transaction
525
#End transaction
508
$schema->storage->txn_rollback;
526
$schema->storage->txn_rollback;
509
- 

Return to bug 24083