View | Details | Raw Unified | Return to bug 18821
Collapse All | Expand All

(-)a/t/db_dependent/Members.t (-4 / +26 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 62;
20
use Test::More tests => 65;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Exception;
22
use Test::Exception;
23
23
Lines 358-363 t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' ); Link Here
358
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login;
358
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login;
359
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
360
361
my $session = new CGI::Session( undef, undef, { Directory => File::Spec->tmpdir } );
362
361
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 });
363
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 });
362
my $last_seen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen;
364
my $last_seen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen;
363
isnt( $last_seen, undef, 'Lastseen should be changed now' );
365
isnt( $last_seen, undef, 'Lastseen should be changed now' );
Lines 365-376 isnt( $last_seen, undef, 'Lastseen should be changed now' ); Link Here
365
# Last seen shouldn't be updated a second time for this session
367
# Last seen shouldn't be updated a second time for this session
366
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' );
368
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' );
367
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login();
369
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login();
368
is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, $last_seen, 'Lastseen should not be changed' );
370
my $new_lastseen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen;
371
is( $new_lastseen, $last_seen, 'Lastseen should not be changed' );
369
372
370
# If it's forced, it should still be updated
373
# 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
374
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 });
375
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' );
376
$new_lastseen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen; 
377
isnt( $new_lastseen, $last_seen, 'Lastseen should be changed if forced' );
378
379
# Pass in a session, don't force update, it shouldn't be needed since session is fresh
380
sleep(1);
381
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ session => $session, force => 0 });
382
$new_lastseen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen; 
383
isnt( $new_lastseen, $last_seen, 'Lastseen should be changed if using a fresh session' );
384
385
# Pass in a session, don't force update, lastseen should be unchanged
386
$last_seen = $new_lastseen;
387
sleep(1);
388
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ session => $session, force => 0 });
389
$new_lastseen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen; 
390
is( $new_lastseen, $last_seen, 'Lastseen should be unchanged with existing session' );
391
392
# Pass in the existing session, force update, lastseen should change
393
sleep(1);
394
Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ session => $session, force => 1 });
395
$new_lastseen = Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen; 
396
isnt( $new_lastseen, $last_seen, 'Lastseen should be changed if forced with existing session' );
374
397
375
398
376
# Regression tests for BZ13502
399
# Regression tests for BZ13502
377
- 

Return to bug 18821