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

(-)a/t/db_dependent/SIP/Message.t (-2 / +85 lines)
Lines 21-27 Link Here
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
22
22
23
use Modern::Perl;
23
use Modern::Perl;
24
use Test::More tests => 19;
24
use Test::More tests => 20;
25
use Test::Exception;
25
use Test::Exception;
26
use Test::MockObject;
26
use Test::MockObject;
27
use Test::MockModule;
27
use Test::MockModule;
Lines 249-254 subtest 'Lastseen response patron info' => sub { Link Here
249
249
250
};
250
};
251
251
252
subtest 'Fine items, currency, start and end item response in patron info' => sub {
253
254
    plan tests => 6;
255
256
    my $schema = Koha::Database->new->schema;
257
    $schema->storage->txn_begin;
258
259
    my $builder    = t::lib::TestBuilder->new();
260
    my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
261
    my ( $response, $findpatron );
262
    my $mocks             = create_mocks( \$response, \$findpatron, \$branchcode );
263
    my $patron_with_fines = $builder->build(
264
        {
265
            source => 'Borrower',
266
            value  => {
267
                password   => hash_password(PATRON_PW),
268
                branchcode => $branchcode,
269
            },
270
        }
271
    );
272
273
    # SIP2 currency field is limited to 3 chars
274
    my $currency = substr Koha::Acquisition::Currencies->get_active->currency,
275
        0, 3;
276
277
    my $account = Koha::Account->new( { patron_id => $patron_with_fines->{borrowernumber} } );
278
279
    my $amount1 = '1.00';
280
    my $amount2 = '2.00';
281
    my $amount3 = '3.00';
282
283
    my $debt1 = $account->add_debit( { type => 'ACCOUNT', amount => $amount1, interface => 'commandline' } );
284
    my $debt2 = $account->add_debit( { type => 'ACCOUNT', amount => $amount2, interface => 'commandline' } );
285
    my $debt3 = $account->add_debit( { type => 'ACCOUNT', amount => $amount3, interface => 'commandline' } );
286
287
    my $cardnum    = $patron_with_fines->{cardnumber};
288
    my $sip_patron = C4::SIP::ILS::Patron->new($cardnum);
289
    $findpatron = $sip_patron;
290
291
    my $siprequest =
292
          PATRON_INFO
293
        . 'engYYYYMMDDZZZZHHMMSS'
294
        . '      Y   '
295
        . FID_INST_ID
296
        . $branchcode . '|'
297
        . FID_PATRON_ID
298
        . $cardnum . '|'
299
        . FID_PATRON_PWD
300
        . PATRON_PW . '|'
301
        . FID_START_ITEM . '2|'
302
        . FID_END_ITEM . '3|';
303
    my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
304
305
    my $server = { ils => $mocks->{ils} };
306
    undef $response;
307
    $msg->handle_patron_info($server);
308
309
    isnt( $response, undef, 'At least we got a response.' );
310
    my $respcode = substr( $response, 0, 2 );
311
    is( $respcode, PATRON_INFO_RESP, 'Response code fine' );
312
313
    check_field(
314
        $respcode, $response, FID_CURRENCY, $currency,
315
        'Verified active currency'
316
    );
317
318
    # the following checks apply to fields which can occur several times
319
    isnt(
320
        $response =~ /\|${\FID_FINE_ITEMS} $amount1/,
321
        1, 'Verified fine item 1 is not in response'
322
    );
323
    is(
324
        $response =~ /\|${\FID_FINE_ITEMS}\s$amount2/,
325
        1, 'Verified fine item 2'
326
    );
327
    is(
328
        $response =~ /\|${\FID_FINE_ITEMS}\s$amount3/,
329
        1, 'Verified fine item 3'
330
    );
331
332
    $schema->storage->txn_rollback;
333
};
334
335
252
subtest "Test patron_status_string" => sub {
336
subtest "Test patron_status_string" => sub {
253
    my $schema = Koha::Database->new->schema;
337
    my $schema = Koha::Database->new->schema;
254
    $schema->storage->txn_begin;
338
    $schema->storage->txn_begin;
255
- 

Return to bug 23426