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

(-)a/t/db_dependent/Circulation/issue.t (-56 / +32 lines)
Lines 36-41 use Koha::Items; Link Here
36
use Koha::Library;
36
use Koha::Library;
37
use Koha::Patrons;
37
use Koha::Patrons;
38
use Koha::CirculationRules;
38
use Koha::CirculationRules;
39
use Koha::Statistics;
39
40
40
BEGIN {
41
BEGIN {
41
    require_ok('C4::Circulation');
42
    require_ok('C4::Circulation');
Lines 248-308 subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub { Link Here
248
249
249
    $se->mock( 'interface', sub { return 'opac' } );
250
    $se->mock( 'interface', sub { return 'opac' } );
250
251
251
    t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'opacrenew' );
252
    my $item_library = $builder->build_object( { class => 'Koha::Libraries' } );
252
    my $item = $builder->build_sample_item({ itype => $itemtype});
253
    my $patron       = $builder->build_object( { class => 'Koha::Patrons' } );
253
    my $opac_renew_issue = C4::Circulation::AddIssue( $borrower_1, $item->barcode );
254
    my $logged_in_user = $builder->build_object( { class => 'Koha::Patrons' } );
254
    AddRenewal(
255
    t::lib::Mocks::mock_userenv( { patron => $logged_in_user } );
255
        $borrower_id1,
256
256
        $item->itemnumber,
257
    my $OpacRenewalBranch = {
257
        "Stavromula", $datedue1, $daysago10
258
        opacrenew        => "OPACRenew",
258
    );
259
        checkoutbranch   => $logged_in_user->branchcode,
259
    my $stat = $schema->resultset('Statistic')->search({ itemnumber => $item->itemnumber, type => 'renew' })->next;
260
        patronhomebranch => $patron->branchcode,
260
    is( $stat->branch, "OPACRenew", "OpacRenewalBranch is respected for OpacRenewalBranch = OPACRenew" );
261
        itemhomebranch   => $item_library->branchcode,
261
262
        none             => "",
262
    t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'checkoutbranch' );
263
    };
263
    my $item2 = $builder->build_sample_item({ itype => $itemtype});
264
264
    $opac_renew_issue = C4::Circulation::AddIssue( $borrower_1, $item2->barcode );
265
    while ( my ( $syspref, $expected_branchcode ) = each %$OpacRenewalBranch ) {
265
    AddRenewal(
266
266
        $borrower_id1,
267
        t::lib::Mocks::mock_preference( 'OpacRenewalBranch', $syspref );
267
        $item2->itemnumber,
268
268
        "Stavromula", $datedue1, $daysago10
269
        my $item = $builder->build_sample_item(
269
    );
270
            { library => $item_library->branchcode, itype => $itemtype } );
270
    $stat = $schema->resultset('Statistic')->search({ itemnumber => $item2->itemnumber, type => 'renew' })->next;
271
        my $opac_renew_issue =
271
    is( $stat->branch, $patron_1->branchcode, "OpacRenewalBranch is respected for OpacRenewalBranch = checkoutbranch" );
272
          C4::Circulation::AddIssue( $patron->unblessed, $item->barcode );
272
273
273
    t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'patronhomebranch' );
274
        AddRenewal( $patron->borrowernumber, $item->itemnumber,
274
    my $item3 = $builder->build_sample_item({ itype => $itemtype});
275
            "Stavromula", $datedue1, $daysago10 );
275
    $opac_renew_issue = C4::Circulation::AddIssue( $borrower_1, $item3->barcode );
276
276
    AddRenewal(
277
        my $stat = Koha::Statistics->search(
277
        $borrower_id1,
278
            { itemnumber => $item->itemnumber, type => 'renew' } )->next;
278
        $item3->itemnumber,
279
        is( $stat->branch, $expected_branchcode,
279
        "Stavromula", $datedue1, $daysago10
280
            "->renewal_branchcode is respected for OpacRenewalBranch = $syspref"
280
    );
281
        );
281
    $stat = $schema->resultset('Statistic')->search({ itemnumber => $item3->itemnumber, type => 'renew' })->next;
282
    }
282
    my $patron = Koha::Patrons->find( $borrower_id1 );
283
    is( $stat->branch, $patron->branchcode, "OpacRenewalBranch is respected for OpacRenewalBranch = patronhomebranch" );
284
285
    t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'itemhomebranch' );
286
    my $item4 = $builder->build_sample_item({ itype => $itemtype});
287
    $opac_renew_issue = C4::Circulation::AddIssue( $borrower_1, $item4->barcode );
288
    AddRenewal(
289
        $borrower_id1,
290
        $item4->itemnumber,
291
        "Stavromula", $datedue1, $daysago10
292
    );
293
    $stat = $schema->resultset('Statistic')->search({ itemnumber => $item4->itemnumber, type => 'renew' })->next;
294
    is( $stat->branch, $item4->homebranch, "OpacRenewalBranch is respected for OpacRenewalBranch = itemhomebranch" );
295
296
    t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'none' );
297
    my $item5 = $builder->build_sample_item({ itype => $itemtype});
298
    $opac_renew_issue = C4::Circulation::AddIssue( $borrower_1, $item5->barcode );
299
    AddRenewal(
300
        $borrower_id1,
301
        $item5->itemnumber,
302
        "Stavromula", $datedue1, $daysago10
303
    );
304
    $stat = $schema->resultset('Statistic')->search({ itemnumber => $item5->itemnumber, type => 'renew' })->next;
305
    is( $stat->branch, "", "OpacRenewalBranch is respected for OpacRenewalBranch none" );
306
};
283
};
307
284
308
#Test GetBiblioIssues
285
#Test GetBiblioIssues
309
- 

Return to bug 24754