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

(-)a/t/db_dependent/Circulation.t (-1 / +48 lines)
Lines 117-122 $cache->clear_from_cache('single_holidays'); Link Here
117
$dbh->do('DELETE FROM issues');
117
$dbh->do('DELETE FROM issues');
118
$dbh->do('DELETE FROM borrowers');
118
$dbh->do('DELETE FROM borrowers');
119
119
120
# Disable recording of issuer until we're ready for it
121
t::lib::Mocks::mock_preference('RecordIssuer', 0);
122
123
my $module = new Test::MockModule('C4::Context');
124
120
my $library = $builder->build({
125
my $library = $builder->build({
121
    source => 'Branch',
126
    source => 'Branch',
122
});
127
});
Lines 3454-3460 subtest 'Incremented fee tests' => sub { Link Here
3454
    my $library =
3459
    my $library =
3455
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3460
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3456
3461
3457
    my $module = new Test::MockModule('C4::Context');
3458
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3462
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3459
3463
3460
    my $patron = $builder->build_object(
3464
    my $patron = $builder->build_object(
Lines 3733-3738 subtest "Test Backdating of Returns" => sub { Link Here
3733
    is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' );
3737
    is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' );
3734
};
3738
};
3735
3739
3740
subtest 'AddIssue records issuer if appropriate' => sub  {
3741
    plan tests => 2;
3742
3743
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
3744
3745
    my $library =
3746
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3747
    my $patron = $builder->build_object(
3748
        {
3749
            class => 'Koha::Patrons',
3750
            value => { categorycode => $patron_category->{categorycode} }
3751
        }
3752
    )->store;
3753
    my $issuer = $builder->build_object(
3754
        {
3755
            class => 'Koha::Patrons',
3756
            value => { categorycode => $patron_category->{categorycode} }
3757
        }
3758
    )->store;
3759
    my $item = $builder->build_sample_item(
3760
        {
3761
            library  => $library->{branchcode}
3762
        }
3763
    );
3764
3765
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
3766
3767
    my $dt_from     = dt_from_string();
3768
    my $dt_to       = dt_from_string()->add( days => 7 );
3769
3770
    my $issue =
3771
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3772
3773
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
3774
3775
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
3776
3777
    my $issue2 =
3778
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3779
3780
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
3781
};
3782
3736
$schema->storage->txn_rollback;
3783
$schema->storage->txn_rollback;
3737
C4::Context->clear_syspref_cache();
3784
C4::Context->clear_syspref_cache();
3738
$cache->clear_from_cache('single_holidays');
3785
$cache->clear_from_cache('single_holidays');
(-)a/t/db_dependent/Koha/Checkouts.t (-1 / +30 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 7;
22
use Test::More tests => 8;
23
23
24
use C4::Circulation;
24
use C4::Circulation;
25
use Koha::Checkouts;
25
use Koha::Checkouts;
Lines 122-127 subtest 'patron' => sub { Link Here
122
    );
122
    );
123
};
123
};
124
124
125
subtest 'issuer' => sub {
126
    plan tests => 3;
127
    my $patron = $builder->build_object({class=>'Koha::Patrons', value => {branchcode => $library->{branchcode}}});
128
    my $issuer = $builder->build_object({class=>'Koha::Patrons', value => {branchcode => $library->{branchcode}}});
129
130
    my $item = $builder->build_object( { class=> 'Koha::Items' } );
131
    my $checkout = Koha::Checkout->new({
132
        borrowernumber => $patron->borrowernumber,
133
        issuer         => $issuer->borrowernumber,
134
        itemnumber     => $item->itemnumber,
135
        branchcode     => $library->{branchcode},
136
    })->store;
137
138
    my $i = $checkout->issued_by;
139
    is( ref($i), 'Koha::Patron',
140
        'Koha::Checkout->issued_by should return a Koha::Patron' );
141
    is( $i->borrowernumber, $issuer->borrowernumber,
142
        'Koha::Checkout->issued_by should return the correct patron' );
143
144
    my $issue_id = $checkout->issue_id;
145
    C4::Circulation::MarkIssueReturned( $i->borrowernumber, $checkout->itemnumber );
146
    $i->delete;
147
    my $old_issue = Koha::Old::Checkouts->find($issue_id);
148
    is( $old_issue->issuer, undef,
149
        'Koha::Checkout->issuer should return undef if the patron record has been deleted'
150
    );
151
152
};
153
125
$retrieved_checkout_1->delete;
154
$retrieved_checkout_1->delete;
126
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' );
155
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' );
127
156
(-)a/t/db_dependent/Koha/Patrons.t (-1 / +7 lines)
Lines 1415-1420 subtest 'get_overdues' => sub { Link Here
1415
            value  => { branchcode => $library->{branchcode} }
1415
            value  => { branchcode => $library->{branchcode} }
1416
        }
1416
        }
1417
    );
1417
    );
1418
    my $issuer = $builder->build(
1419
        {
1420
            source => 'Borrower',
1421
            value  => { branchcode => $library->{branchcode} }
1422
        }
1423
    );
1424
    t::lib::Mocks::mock_userenv({ number => $issuer->{borrowernumber} });
1418
1425
1419
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1426
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1420
1427
1421
- 

Return to bug 23916