|
Lines 2386-2406
subtest 'alert_subscriptions tests' => sub {
Link Here
|
| 2386 |
|
2386 |
|
| 2387 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
2387 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 2388 |
|
2388 |
|
| 2389 |
my $subscription1 = $builder->build_object( { |
2389 |
my $subscription1 = $builder->build_object( |
| 2390 |
class => 'Koha::Subscriptions', |
2390 |
{ |
| 2391 |
value => { |
2391 |
class => 'Koha::Subscriptions', |
| 2392 |
librarian => $patron->borrowernumber, |
2392 |
value => { |
|
|
2393 |
librarian => $patron->borrowernumber, |
| 2394 |
} |
| 2393 |
} |
2395 |
} |
| 2394 |
}); |
2396 |
); |
| 2395 |
$subscription1->add_subscriber($patron); |
2397 |
$subscription1->add_subscriber($patron); |
| 2396 |
|
2398 |
|
| 2397 |
|
2399 |
my $subscription2 = $builder->build_object( |
| 2398 |
my $subscription2 = $builder->build_object( { |
2400 |
{ |
| 2399 |
class => 'Koha::Subscriptions', |
2401 |
class => 'Koha::Subscriptions', |
| 2400 |
value => { |
2402 |
value => { |
| 2401 |
librarian => $patron->borrowernumber, |
2403 |
librarian => $patron->borrowernumber, |
|
|
2404 |
} |
| 2402 |
} |
2405 |
} |
| 2403 |
}); |
2406 |
); |
| 2404 |
$subscription2->add_subscriber($patron); |
2407 |
$subscription2->add_subscriber($patron); |
| 2405 |
|
2408 |
|
| 2406 |
my @subscriptions = $patron->alert_subscriptions->as_list; |
2409 |
my @subscriptions = $patron->alert_subscriptions->as_list; |
|
Lines 2439-2454
subtest 'update_lastseen tests' => sub {
Link Here
|
| 2439 |
my $mock_cache = Test::MockModule->new('Koha::Cache'); |
2442 |
my $mock_cache = Test::MockModule->new('Koha::Cache'); |
| 2440 |
my %fake_cache; |
2443 |
my %fake_cache; |
| 2441 |
|
2444 |
|
| 2442 |
$mock_cache->mock('set_in_cache', sub { |
2445 |
$mock_cache->mock( |
| 2443 |
my ( $self, $key, $value ) = @_; |
2446 |
'set_in_cache', |
| 2444 |
$fake_cache{$key} = $value; |
2447 |
sub { |
| 2445 |
return; |
2448 |
my ( $self, $key, $value ) = @_; |
| 2446 |
}); |
2449 |
$fake_cache{$key} = $value; |
|
|
2450 |
return; |
| 2451 |
} |
| 2452 |
); |
| 2447 |
|
2453 |
|
| 2448 |
$mock_cache->mock('get_from_cache', sub { |
2454 |
$mock_cache->mock( |
| 2449 |
my ( $self, $key ) = @_; |
2455 |
'get_from_cache', |
| 2450 |
return $fake_cache{$key}; |
2456 |
sub { |
| 2451 |
}); |
2457 |
my ( $self, $key ) = @_; |
|
|
2458 |
return $fake_cache{$key}; |
| 2459 |
} |
| 2460 |
); |
| 2452 |
|
2461 |
|
| 2453 |
my $cache = Koha::Caches->get_instance(); |
2462 |
my $cache = Koha::Caches->get_instance(); |
| 2454 |
|
2463 |
|
|
Lines 2457-2468
subtest 'update_lastseen tests' => sub {
Link Here
|
| 2457 |
'creation,login,connection,check_in,check_out,renewal,hold,article' |
2466 |
'creation,login,connection,check_in,check_out,renewal,hold,article' |
| 2458 |
); |
2467 |
); |
| 2459 |
|
2468 |
|
| 2460 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
2469 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 2461 |
my $patron_info = $patron->unblessed; |
2470 |
my $patron_info = $patron->unblessed; |
| 2462 |
delete $patron_info->{borrowernumber}; |
2471 |
delete $patron_info->{borrowernumber}; |
| 2463 |
$patron->delete(); |
2472 |
$patron->delete(); |
| 2464 |
$patron = Koha::Patron->new($patron_info)->store(); |
2473 |
$patron = Koha::Patron->new($patron_info)->store(); |
| 2465 |
$patron->update_lastseen({ activity => 'creation' }); |
2474 |
$patron->update_lastseen( { activity => 'creation' } ); |
| 2466 |
$patron->discard_changes(); |
2475 |
$patron->discard_changes(); |
| 2467 |
|
2476 |
|
| 2468 |
my $now = dt_from_string(); |
2477 |
my $now = dt_from_string(); |
|
Lines 2486-2505
subtest 'update_lastseen tests' => sub {
Link Here
|
| 2486 |
|
2495 |
|
| 2487 |
$patron_no_trigger->lastseen(undef)->store(); |
2496 |
$patron_no_trigger->lastseen(undef)->store(); |
| 2488 |
|
2497 |
|
| 2489 |
$patron_no_trigger->update_lastseen({ activity => 'login' }); |
2498 |
$patron_no_trigger->update_lastseen( { activity => 'login' } ); |
| 2490 |
$patron_no_trigger->discard_changes(); |
2499 |
$patron_no_trigger->discard_changes(); |
| 2491 |
|
2500 |
|
| 2492 |
is( $patron_no_trigger->lastseen, undef, |
2501 |
is( |
|
|
2502 |
$patron_no_trigger->lastseen, undef, |
| 2493 |
'Patron should have not last seen when newly created if trigger not set' |
2503 |
'Patron should have not last seen when newly created if trigger not set' |
| 2494 |
); |
2504 |
); |
| 2495 |
|
2505 |
|
| 2496 |
|
|
|
| 2497 |
t::lib::Mocks::mock_preference( |
2506 |
t::lib::Mocks::mock_preference( |
| 2498 |
'TrackLastPatronActivityTriggers', |
2507 |
'TrackLastPatronActivityTriggers', |
| 2499 |
'login,connection,check_in,check_out,renewal,hold,article' |
2508 |
'login,connection,check_in,check_out,renewal,hold,article' |
| 2500 |
); |
2509 |
); |
| 2501 |
|
2510 |
|
| 2502 |
|
|
|
| 2503 |
$now = dt_from_string(); |
2511 |
$now = dt_from_string(); |
| 2504 |
Time::Fake->offset( $now->epoch ); |
2512 |
Time::Fake->offset( $now->epoch ); |
| 2505 |
|
2513 |
|