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 => 50;
21
use Test::More tests => 51;
22
use Test::Exception;
22
use Test::Exception;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Deep qw( cmp_deeply );
24
use Test::Deep qw( cmp_deeply );
Lines 122-127 for my $branch ( $branches->next ) { Link Here
122
$dbh->do('DELETE FROM issues');
122
$dbh->do('DELETE FROM issues');
123
$dbh->do('DELETE FROM borrowers');
123
$dbh->do('DELETE FROM borrowers');
124
124
125
# Disable recording of issuer until we're ready for it
126
t::lib::Mocks::mock_preference('RecordIssuer', 0);
127
128
my $module = new Test::MockModule('C4::Context');
129
125
my $library = $builder->build({
130
my $library = $builder->build({
126
    source => 'Branch',
131
    source => 'Branch',
127
});
132
});
Lines 3797-3803 subtest 'Incremented fee tests' => sub { Link Here
3797
    my $library =
3802
    my $library =
3798
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3803
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3799
3804
3800
    my $module = Test::MockModule->new('C4::Context');
3801
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3805
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3802
3806
3803
    my $patron = $builder->build_object(
3807
    my $patron = $builder->build_object(
Lines 4599-4604 subtest 'Checkout should correctly terminate a transfer' => sub { Link Here
4599
    $hold = $hold->get_from_storage;
4603
    $hold = $hold->get_from_storage;
4600
    is( $hold->found, undef, 'Hold is waiting' );
4604
    is( $hold->found, undef, 'Hold is waiting' );
4601
    is( $hold->priority, 1, );
4605
    is( $hold->priority, 1, );
4606
}
4607
4608
subtest 'AddIssue records issuer if appropriate' => sub  {
4609
    plan tests => 2;
4610
4611
    $module->mock( 'userenv', sub { { branch => $library->{id} } } );
4612
4613
    my $library =
4614
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
4615
    my $patron = $builder->build_object(
4616
        {
4617
            class => 'Koha::Patrons',
4618
            value => { categorycode => $patron_category->{categorycode} }
4619
        }
4620
    )->store;
4621
    my $issuer = $builder->build_object(
4622
        {
4623
            class => 'Koha::Patrons',
4624
            value => { categorycode => $patron_category->{categorycode} }
4625
        }
4626
    )->store;
4627
    my $item = $builder->build_sample_item(
4628
        {
4629
            library  => $library->{branchcode}
4630
        }
4631
    );
4632
4633
    $module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
4634
4635
    my $dt_from     = dt_from_string();
4636
    my $dt_to       = dt_from_string()->add( days => 7 );
4637
4638
    my $issue =
4639
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4640
4641
    is( $issue->issuer, undef, "Issuer not recorded when RecordIssuer turned off" );
4642
4643
    t::lib::Mocks::mock_preference('RecordIssuer', 1);
4644
4645
    my $issue2 =
4646
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
4647
4648
    is( $issue->issuer, $issuer->{borrowernumber}, "Issuer recorded when RecordIssuer turned on" );
4602
};
4649
};
4603
4650
4604
$schema->storage->txn_rollback;
4651
$schema->storage->txn_rollback;
(-)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 1430-1435 subtest 'get_overdues' => sub { Link Here
1430
            value  => { branchcode => $library->{branchcode} }
1430
            value  => { branchcode => $library->{branchcode} }
1431
        }
1431
        }
1432
    );
1432
    );
1433
    my $issuer = $builder->build(
1434
        {
1435
            source => 'Borrower',
1436
            value  => { branchcode => $library->{branchcode} }
1437
        }
1438
    );
1439
    t::lib::Mocks::mock_userenv({ number => $issuer->{borrowernumber} });
1433
1440
1434
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1441
    t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} });
1435
1442
1436
- 

Return to bug 23916