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

(-)a/t/db_dependent/Overdues.t (-2 / +100 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl;
1
#!/usr/bin/perl;
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 19;
4
use Test::More tests => 20;
5
use Test::NoWarnings;
5
use Test::NoWarnings;
6
use Test::Warn;
6
use Test::Warn;
7
7
Lines 163-168 is_deeply( \@overdue_branches, [ 'CPL', 'MPL' ], 'If only 2 specific rules exist Link Here
163
163
164
$schema->storage->txn_rollback;
164
$schema->storage->txn_rollback;
165
165
166
subtest 'branch_for_fee_context' => sub {
167
    plan tests => 8;
168
    $schema->storage->txn_begin;
169
170
    my $br_home = $builder->build( { source => 'Branch' } )->{branchcode};
171
    my $br_hold = $builder->build( { source => 'Branch' } )->{branchcode};
172
    my $br_pat  = $builder->build( { source => 'Branch' } )->{branchcode};
173
174
    my $pat1 = $builder->build_object(
175
        {
176
            class => 'Koha::Patrons',
177
            value => { branchcode => $br_pat }
178
        }
179
    );
180
181
    my $item1 = $builder->build_object(
182
        {
183
            class => 'Koha::Items',
184
            value => { homebranch => $br_home, holdingbranch => $br_hold }
185
        }
186
    );
187
188
    my $issue1 = $builder->build_object(
189
        {
190
            class => 'Koha::Checkouts',
191
            value => {
192
                itemnumber     => $item1->itemnumber,
193
                borrowernumber => $pat1->borrowernumber,
194
                branchcode     => $br_hold,
195
            }
196
        }
197
    );
198
199
    t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' );
200
    t::lib::Mocks::mock_preference( 'CircControl',         'PatronLibrary' );
201
    is(
202
        C4::Overdues::branch_for_fee_context(
203
            fee_type => 'OVERDUE', patron => $pat1, item => $item1, issue => $issue1
204
        ),
205
        $br_pat,
206
        'OVERDUE: PatronLibrary => patron home'
207
    );
208
209
    t::lib::Mocks::mock_preference( 'CircControl', 'PickupLibrary' );
210
    is(
211
        C4::Overdues::branch_for_fee_context(
212
            fee_type => 'OVERDUE', patron => $pat1, item => $item1, issue => $issue1
213
        ),
214
        $br_hold,
215
        'OVERDUE: PickupLibrary => issuing branch'
216
    );
217
218
    t::lib::Mocks::mock_preference( 'CircControl',         'ItemHomeLibrary' );
219
    t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' );
220
    is(
221
        C4::Overdues::branch_for_fee_context(
222
            fee_type => 'OVERDUE', patron => $pat1, item => $item1, issue => $issue1
223
        ),
224
        $br_home,
225
        'OVERDUE: ItemHomeLibrary/homebranch => item home'
226
    );
227
228
    t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'holdingbranch' );
229
    is(
230
        C4::Overdues::branch_for_fee_context(
231
            fee_type => 'OVERDUE', patron => $pat1, item => $item1, issue => $issue1
232
        ),
233
        $br_hold,
234
        'OVERDUE: ItemHomeLibrary/holdingbranch => item holding'
235
    );
236
237
    t::lib::Mocks::mock_preference( 'LostChargesControl',  'PatronLibrary' );
238
    t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' );
239
    is(
240
        C4::Overdues::branch_for_fee_context( fee_type => 'LOST', patron => $pat1, item => $item1, issue => $issue1 ),
241
        $br_pat, 'LOST: PatronLibrary => patron home'
242
    );
243
244
    t::lib::Mocks::mock_preference( 'LostChargesControl', 'PickupLibrary' );
245
    is(
246
        C4::Overdues::branch_for_fee_context( fee_type => 'LOST', patron => $pat1, item => $item1, issue => $issue1 ),
247
        $br_hold, 'LOST: PickupLibrary => issuing branch'
248
    );
249
250
    t::lib::Mocks::mock_preference( 'LostChargesControl',  'ItemHomeLibrary' );
251
    t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' );
252
    is(
253
        C4::Overdues::branch_for_fee_context( fee_type => 'LOST', patron => $pat1, item => $item1, issue => $issue1 ),
254
        $br_home, 'LOST: ItemHomeLibrary/homebranch => item home'
255
    );
256
257
    t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'holdingbranch' );
258
    is(
259
        C4::Overdues::branch_for_fee_context( fee_type => 'LOST', patron => $pat1, item => $item1, issue => $issue1 ),
260
        $br_hold, 'LOST: ItemHomeLibrary/holdingbranch => item holding'
261
    );
262
    $schema->storage->txn_rollback;
263
};
264
166
subtest 'UpdateFine tests' => sub {
265
subtest 'UpdateFine tests' => sub {
167
266
168
    plan tests => 75;
267
    plan tests => 75;
169
- 

Return to bug 35612