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

(-)a/t/db_dependent/Circulation.t (-1 / +48 lines)
Lines 121-126 for my $branch ( $branches->next ) { Link Here
121
$dbh->do('DELETE FROM issues');
121
$dbh->do('DELETE FROM issues');
122
$dbh->do('DELETE FROM borrowers');
122
$dbh->do('DELETE FROM borrowers');
123
123
124
# Disable recording of issuer until we're ready for it
125
t::lib::Mocks::mock_preference('RecordIssuer', 0);
126
127
my $module = new Test::MockModule('C4::Context');
128
124
my $library = $builder->build({
129
my $library = $builder->build({
125
    source => 'Branch',
130
    source => 'Branch',
126
});
131
});
Lines 3313-3319 subtest 'Incremented fee tests' => sub { Link Here
3313
    my $library =
3318
    my $library =
3314
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3319
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3315
3320
3316
    my $module = new Test::MockModule('C4::Context');
3317
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3321
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3318
3322
3319
    my $patron = $builder->build_object(
3323
    my $patron = $builder->build_object(
Lines 4060-4065 subtest 'transferbook tests' => sub { Link Here
4060
4064
4061
};
4065
};
4062
4066
4067
subtest 'AddIssue records issuer if appropriate' => sub  {
4068
    plan tests => 2;
4069
4070
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4071
4072
    my $library =
4073
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
4074
    my $patron = $builder->build_object(
4075
        {
4076
            class => 'Koha::Patrons',
4077
            value => { categorycode => $patron_category->{categorycode} }
4078
        }
4079
    )->store;
4080
    my $issuer = $builder->build_object(
4081
        {
4082
            class => 'Koha::Patrons',
4083
            value => { categorycode => $patron_category->{categorycode} }
4084
        }
4085
    )->store;
4086
    my $item = $builder->build_sample_item(
4087
        {
4088
            library  => $library->{branchcode}
4089
        }
4090
    );
4091
4092
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
4093
4094
    my $dt_from     = dt_from_string();
4095
    my $dt_to       = dt_from_string()->add( days => 7 );
4096
4097
    my $issue =
4098
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4099
4100
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
4101
4102
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
4103
4104
    my $issue2 =
4105
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4106
4107
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
4108
};
4109
4063
$schema->storage->txn_rollback;
4110
$schema->storage->txn_rollback;
4064
C4::Context->clear_syspref_cache();
4111
C4::Context->clear_syspref_cache();
4065
$branches = Koha::Libraries->search();
4112
$branches = Koha::Libraries->search();
(-)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 1421-1426 subtest 'get_overdues' => sub { Link Here
1421
            value  => { branchcode => $library->{branchcode} }
1421
            value  => { branchcode => $library->{branchcode} }
1422
        }
1422
        }
1423
    );
1423
    );
1424
    my $issuer = $builder->build(
1425
        {
1426
            source => 'Borrower',
1427
            value  => { branchcode => $library->{branchcode} }
1428
        }
1429
    );
1430
    t::lib::Mocks::mock_userenv({ number => $issuer->{borrowernumber} });
1424
1431
1425
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1432
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1426
1433
1427
- 

Return to bug 23916