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