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 => 18; |
24 |
use Test::More tests => 19; |
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 196-202
subtest 'hold_patron_name() tests' => sub {
Link Here
|
196 |
$schema->storage->txn_rollback; |
196 |
$schema->storage->txn_rollback; |
197 |
}; |
197 |
}; |
198 |
|
198 |
|
199 |
subtest 'Lastseen response' => sub { |
199 |
subtest 'Lastseen response patron info' => sub { |
200 |
|
200 |
|
201 |
plan tests => 6; |
201 |
plan tests => 6; |
202 |
|
202 |
|
Lines 342-347
subtest "Test patron_status_string" => sub {
Link Here
|
342 |
$schema->storage->txn_rollback; |
342 |
$schema->storage->txn_rollback; |
343 |
}; |
343 |
}; |
344 |
|
344 |
|
|
|
345 |
subtest 'Lastseen response patron status' => sub { |
346 |
|
347 |
plan tests => 6; |
348 |
|
349 |
my $schema = Koha::Database->new->schema; |
350 |
$schema->storage->txn_begin; |
351 |
|
352 |
my $builder = t::lib::TestBuilder->new(); |
353 |
my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; |
354 |
my ( $response, $findpatron ); |
355 |
my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); |
356 |
my $seen_patron = $builder->build( |
357 |
{ |
358 |
source => 'Borrower', |
359 |
value => { |
360 |
lastseen => '2001-01-01', |
361 |
password => hash_password(PATRON_PW), |
362 |
branchcode => $branchcode, |
363 |
}, |
364 |
} |
365 |
); |
366 |
my $cardnum = $seen_patron->{cardnumber}; |
367 |
my $sip_patron = C4::SIP::ILS::Patron->new($cardnum); |
368 |
$findpatron = $sip_patron; |
369 |
|
370 |
my $siprequest = |
371 |
PATRON_STATUS_REQ |
372 |
. 'engYYYYMMDDZZZZHHMMSS' |
373 |
. FID_INST_ID |
374 |
. $branchcode . '|' |
375 |
. FID_PATRON_ID |
376 |
. $cardnum . '|' |
377 |
. FID_PATRON_PWD |
378 |
. PATRON_PW . '|'; |
379 |
my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); |
380 |
|
381 |
my $server = { ils => $mocks->{ils} }; |
382 |
undef $response; |
383 |
|
384 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' ); |
385 |
$msg->handle_patron_status($server); |
386 |
|
387 |
isnt( $response, undef, 'At least we got a response.' ); |
388 |
my $respcode = substr( $response, 0, 2 ); |
389 |
is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); |
390 |
$seen_patron = Koha::Patrons->find( { cardnumber => $seen_patron->{cardnumber} } ); |
391 |
is( |
392 |
output_pref( { str => $seen_patron->lastseen(), dateonly => 1 } ), |
393 |
output_pref( { str => '2001-01-01', dateonly => 1 } ), 'Last seen not updated if not tracking patrons' |
394 |
); |
395 |
undef $response; |
396 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'connection' ); |
397 |
$msg->handle_patron_status($server); |
398 |
|
399 |
isnt( $response, undef, 'At least we got a response.' ); |
400 |
$respcode = substr( $response, 0, 2 ); |
401 |
is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); |
402 |
$seen_patron = Koha::Patrons->find( { cardnumber => $seen_patron->cardnumber() } ); |
403 |
is( |
404 |
output_pref( { str => $seen_patron->lastseen(), dateonly => 1 } ), |
405 |
output_pref( { dt => dt_from_string(), dateonly => 1 } ), 'Last seen updated if tracking patrons' |
406 |
); |
407 |
$schema->storage->txn_rollback; |
408 |
|
409 |
}; |
410 |
|
345 |
subtest "Test build_additional_item_fields_string" => sub { |
411 |
subtest "Test build_additional_item_fields_string" => sub { |
346 |
my $schema = Koha::Database->new->schema; |
412 |
my $schema = Koha::Database->new->schema; |
347 |
$schema->storage->txn_begin; |
413 |
$schema->storage->txn_begin; |
348 |
- |
|
|