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 |
|
353 |
my $builder = t::lib::TestBuilder->new(); |
354 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
355 |
my ( $response, $findpatron ); |
356 |
my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); |
357 |
my $seen_patron = $builder->build({ |
358 |
source => 'Borrower', |
359 |
value => { |
360 |
lastseen => '2001-01-01', |
361 |
password => hash_password( PATRON_PW ), |
362 |
branchcode => $branchcode, |
363 |
}, |
364 |
}); |
365 |
my $cardnum = $seen_patron->{cardnumber}; |
366 |
my $sip_patron = C4::SIP::ILS::Patron->new( $cardnum ); |
367 |
$findpatron = $sip_patron; |
368 |
|
369 |
my $siprequest = PATRON_STATUS_REQ. 'engYYYYMMDDZZZZHHMMSS'. |
370 |
FID_INST_ID. $branchcode. '|'. |
371 |
FID_PATRON_ID. $cardnum. '|'. |
372 |
FID_PATRON_PWD. PATRON_PW. '|'; |
373 |
my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); |
374 |
|
375 |
my $server = { ils => $mocks->{ils} }; |
376 |
undef $response; |
377 |
|
378 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' ); |
379 |
$msg->handle_patron_status( $server ); |
380 |
|
381 |
isnt( $response, undef, 'At least we got a response.' ); |
382 |
my $respcode = substr( $response, 0, 2 ); |
383 |
is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); |
384 |
$seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->{cardnumber} }); |
385 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({str => '2001-01-01', dateonly => 1}),'Last seen not updated if not tracking patrons'); |
386 |
undef $response; |
387 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'connection' ); |
388 |
$msg->handle_patron_status( $server ); |
389 |
|
390 |
isnt( $response, undef, 'At least we got a response.' ); |
391 |
$respcode = substr( $response, 0, 2 ); |
392 |
is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); |
393 |
$seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->cardnumber() }); |
394 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated if tracking patrons'); |
395 |
$schema->storage->txn_rollback; |
396 |
|
397 |
}; |
398 |
|
345 |
subtest "Test build_additional_item_fields_string" => sub { |
399 |
subtest "Test build_additional_item_fields_string" => sub { |
346 |
my $schema = Koha::Database->new->schema; |
400 |
my $schema = Koha::Database->new->schema; |
347 |
$schema->storage->txn_begin; |
401 |
$schema->storage->txn_begin; |
348 |
- |
|
|