Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 60; |
20 |
use Test::More tests => 62; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
|
23 |
|
Lines 350-361
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' });
Link Here
|
350 |
is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' ); |
350 |
is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' ); |
351 |
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' }); |
351 |
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' }); |
352 |
is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' ); |
352 |
is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' ); |
|
|
353 |
|
354 |
|
355 |
# Test method last_seen / TrackLastPatronActivity |
353 |
my $patron2 = $builder->build({ source => 'Borrower', value => { lastseen => undef } }); |
356 |
my $patron2 = $builder->build({ source => 'Borrower', value => { lastseen => undef } }); |
354 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' ); |
357 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' ); |
355 |
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login; |
358 |
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login; |
356 |
is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should not be changed' ); |
359 |
is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should not be changed' ); |
|
|
360 |
|
357 |
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 }); |
361 |
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 }); |
358 |
isnt( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should be changed now' ); |
362 |
my $last_seen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen; |
|
|
363 |
isnt( $last_seen, undef, 'Lastseen should be changed now' ); |
364 |
|
365 |
# Last seen shouldn't be updated a second time for this session |
366 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); |
367 |
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login(); |
368 |
is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, $last_seen, 'Lastseen should not be changed' ); |
369 |
|
370 |
# If it's forced, it should still be updated |
371 |
sleep(1); # We need to wait a tiny bit to make sure the timestamp will be different |
372 |
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 }); |
373 |
isnt( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, $last_seen, 'Lastseen should be changed if forced' ); |
374 |
|
359 |
|
375 |
|
360 |
# Regression tests for BZ13502 |
376 |
# Regression tests for BZ13502 |
361 |
## Remove all entries with userid='' (should be only 1 max) |
377 |
## Remove all entries with userid='' (should be only 1 max) |
362 |
- |
|
|