|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 8; |
22 |
use Test::More tests => 9; |
| 23 |
|
23 |
|
| 24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
| 25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
|
Lines 365-370
subtest 'Add preferences from defaults' => sub {
Link Here
|
| 365 |
$schema->storage->txn_rollback; |
365 |
$schema->storage->txn_rollback; |
| 366 |
}; |
366 |
}; |
| 367 |
|
367 |
|
|
|
368 |
subtest 'Test action logging' => sub { |
| 369 |
plan tests => 8; |
| 370 |
|
| 371 |
$schema->storage->txn_begin; |
| 372 |
|
| 373 |
t::lib::Mocks::mock_preference('BorrowersLog', 1); |
| 374 |
|
| 375 |
my $patron = build_a_test_patron(); |
| 376 |
my ($default, $mtt1, $mtt2) = build_a_test_category_preference({ |
| 377 |
patron => $patron, |
| 378 |
}); |
| 379 |
Koha::Patron::Message::Preference->new_from_default({ |
| 380 |
borrowernumber => $patron->borrowernumber, |
| 381 |
categorycode => $patron->categorycode, |
| 382 |
message_attribute_id => $default->message_attribute_id, |
| 383 |
})->store; |
| 384 |
my $pref = Koha::Patron::Message::Preferences->find({ |
| 385 |
borrowernumber => $patron->borrowernumber, |
| 386 |
message_attribute_id => $default->message_attribute_id, |
| 387 |
}); |
| 388 |
|
| 389 |
my $actionLog = []; |
| 390 |
$pref->_push_to_action_buffer($actionLog); |
| 391 |
is(ref($actionLog), 'ARRAY', 'Action log is an array'); |
| 392 |
is(@{$actionLog}, 1, 'One element in action log'); |
| 393 |
is($actionLog->[0]->{_name}, $pref->message_name, 'Correct message name'); |
| 394 |
is(@{$actionLog->[0]->{mtt}}, keys %{$pref->message_transport_types}, |
| 395 |
'Correct mtts'); |
| 396 |
|
| 397 |
# Let's push it another time for the lulz |
| 398 |
$pref->_push_to_action_buffer($actionLog); |
| 399 |
is(@{$actionLog}, 2, 'Two elements in action log'); |
| 400 |
|
| 401 |
$pref->_log_action_buffer($actionLog, $patron->borrowernumber); |
| 402 |
my $logs = C4::Log::GetLogs("","","",["MEMBERS"],["MOD MTT"], |
| 403 |
$patron->borrowernumber,""); |
| 404 |
is($logs->[0]->{action}, 'MOD MTT', 'Correct log action'); |
| 405 |
is($logs->[0]->{object}, $patron->borrowernumber, 'Correct borrowernumber'); |
| 406 |
|
| 407 |
# Test empty action log buffer |
| 408 |
my $patron2 = build_a_test_patron(); |
| 409 |
$pref->_log_action_buffer([], $patron2->borrowernumber); |
| 410 |
$logs = C4::Log::GetLogs("","","",["MEMBERS"],["MOD MTT"], |
| 411 |
$patron2->borrowernumber,""); |
| 412 |
is($logs->[0]->{info}, 'All message_transport_types removed', 'All message_transport_types removed'); |
| 413 |
|
| 414 |
$schema->storage->txn_rollback; |
| 415 |
}; |
| 416 |
|
| 368 |
subtest 'Test Koha::Patron::Message::Preference->message_transport_types' => sub { |
417 |
subtest 'Test Koha::Patron::Message::Preference->message_transport_types' => sub { |
| 369 |
plan tests => 4; |
418 |
plan tests => 4; |
| 370 |
|
419 |
|
| 371 |
- |
|
|