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

(-)a/t/db_dependent/Circulation.t (-2 / +49 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use utf8;
19
use utf8;
20
20
21
use Test::More tests => 45;
21
use Test::More tests => 46;
22
use Test::MockModule;
22
use Test::MockModule;
23
23
24
use Data::Dumper;
24
use Data::Dumper;
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 3084-3090 subtest 'Incremented fee tests' => sub { Link Here
3084
    my $library =
3089
    my $library =
3085
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3090
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3086
3091
3087
    my $module = new Test::MockModule('C4::Context');
3088
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3092
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3089
3093
3090
    my $patron = $builder->build_object(
3094
    my $patron = $builder->build_object(
Lines 3316-3321 subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub { Link Here
3316
    $itemtype->rentalcharge_daily('0')->store;
3320
    $itemtype->rentalcharge_daily('0')->store;
3317
};
3321
};
3318
3322
3323
subtest 'AddIssue records issuer if appropriate' => sub  {
3324
    plan tests => 2;
3325
3326
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
3327
3328
    my $library =
3329
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3330
    my $patron = $builder->build_object(
3331
        {
3332
            class => 'Koha::Patrons',
3333
            value => { categorycode => $patron_category->{categorycode} }
3334
        }
3335
    )->store;
3336
    my $issuer = $builder->build_object(
3337
        {
3338
            class => 'Koha::Patrons',
3339
            value => { categorycode => $patron_category->{categorycode} }
3340
        }
3341
    )->store;
3342
    my $item = $builder->build_sample_item(
3343
        {
3344
            library  => $library->{branchcode}
3345
        }
3346
    );
3347
3348
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
3349
3350
    my $dt_from     = dt_from_string();
3351
    my $dt_to       = dt_from_string()->add( days => 7 );
3352
3353
    my $issue =
3354
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3355
3356
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
3357
3358
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
3359
3360
    my $issue2 =
3361
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3362
3363
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
3364
};
3365
3319
$schema->storage->txn_rollback;
3366
$schema->storage->txn_rollback;
3320
C4::Context->clear_syspref_cache();
3367
C4::Context->clear_syspref_cache();
3321
$cache->clear_from_cache('single_holidays');
3368
$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 1411-1416 subtest 'get_overdues' => sub { Link Here
1411
            value  => { branchcode => $library->{branchcode} }
1411
            value  => { branchcode => $library->{branchcode} }
1412
        }
1412
        }
1413
    );
1413
    );
1414
    my $issuer = $builder->build(
1415
        {
1416
            source => 'Borrower',
1417
            value  => { branchcode => $library->{branchcode} }
1418
        }
1419
    );
1420
    t::lib::Mocks::mock_userenv({ number => $issuer->{borrowernumber} });
1414
1421
1415
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1422
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1416
1423
1417
- 

Return to bug 23916