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

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

Return to bug 23426