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