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

(-)a/t/db_dependent/Koha/Account.t (-2 / +52 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 16;
23
use Test::More tests => 17;
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::Exception;
25
use Test::Exception;
26
use Test::Warn;
26
use Test::Warn;
Lines 466-471 subtest 'add_debit() tests' => sub { Link Here
466
    $schema->storage->txn_rollback;
466
    $schema->storage->txn_rollback;
467
};
467
};
468
468
469
subtest 'add_debit() populates branchcode according to AccountLinesBranchSource' => sub {
470
    plan tests => 4;
471
472
    $schema->storage->txn_begin;
473
474
    my $patron          = $builder->build_object( { class => 'Koha::Patrons' } );
475
    my $item_homebranch = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
476
    my $checkout_branch = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
477
478
    my $item = $builder->build_sample_item( { homebranch => $item_homebranch } );
479
480
    my $checkout = Koha::Checkout->new(
481
        {
482
            borrowernumber => $patron->id,
483
            itemnumber     => $item->itemnumber,
484
            branchcode     => $checkout_branch,
485
            date_due       => \'NOW()',
486
            issuedate      => \'NOW()',
487
        }
488
    )->store();
489
    my %branch_tests = (
490
        'checkoutbranch'   => $checkout_branch,
491
        'itemhomebranch'   => $item_homebranch,
492
        'patronhomebranch' => $patron->branchcode,
493
        'none'             => undef,
494
    );
495
    for my $pref ( keys %branch_tests ) {
496
        t::lib::Mocks::mock_preference( 'AccountLinesBranchSource', $pref );
497
498
        my $account = $patron->account;
499
500
        my $line = $account->add_debit(
501
            {
502
                amount      => 5,
503
                description => "Test $pref",
504
                type        => 'OVERDUE',
505
                interface   => 'commandline',
506
                item_id     => $item->itemnumber,
507
                issue_id    => $checkout->id,
508
            }
509
        );
510
511
        is(
512
            $line->branchcode,
513
            $branch_tests{$pref},
514
            "branchcode is set correctly for AccountLinesBranchSource = $pref"
515
        );
516
    }
517
    $schema->storage->txn_rollback;
518
};
519
469
subtest 'lines() tests' => sub {
520
subtest 'lines() tests' => sub {
470
521
471
    plan tests => 1;
522
    plan tests => 1;
472
- 

Return to bug 35612