Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
23 |
|
23 |
|
24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
Lines 373-379
HERE
Link Here
|
373 |
is_digest => 1 |
373 |
is_digest => 1 |
374 |
})->store; |
374 |
})->store; |
375 |
t::lib::Mocks::mock_preference('TalkingTechItivaPhoneNotification', 0); |
375 |
t::lib::Mocks::mock_preference('TalkingTechItivaPhoneNotification', 0); |
376 |
$patron->set({ email => '', phone => '', smsalertnumber => '' })->store; |
376 |
$patron->set({ email => '', emailpro => '', B_email => '', phone => '', smsalertnumber => '' })->store; |
377 |
eval { |
377 |
eval { |
378 |
$preference->message_transport_types('email')->store; |
378 |
$preference->message_transport_types('email')->store; |
379 |
}; |
379 |
}; |
Lines 473-478
subtest 'Test Koha::Patron::Message::Preference->message_name' => sub {
Link Here
|
473 |
$schema->storage->txn_rollback; |
473 |
$schema->storage->txn_rollback; |
474 |
}; |
474 |
}; |
475 |
|
475 |
|
|
|
476 |
subtest 'Test Koha::Patron::Message::Preference->mtt_deliverable' => sub { |
477 |
plan tests => 10; |
478 |
|
479 |
$schema->storage->txn_begin; |
480 |
|
481 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
482 |
my ($preference, $mtt1, $mtt2) = build_a_test_complete_preference({ |
483 |
patron => $patron |
484 |
}); |
485 |
|
486 |
# Test email and smsalertnumber validation |
487 |
eval { Koha::Patron::Message::Transport::Types->new({ |
488 |
message_transport_type => 'email' |
489 |
})->store }; |
490 |
eval { Koha::Patron::Message::Transport::Types->new({ |
491 |
message_transport_type => 'sms' |
492 |
})->store }; |
493 |
eval { Koha::Patron::Message::Transport::Types->new({ |
494 |
message_transport_type => 'phone' |
495 |
})->store }; |
496 |
eval { Koha::Patron::Message::Transport::Types->new({ |
497 |
message_transport_type => 'itiva' |
498 |
})->store }; |
499 |
Koha::Patron::Message::Transport->new({ |
500 |
message_attribute_id => $preference->message_attribute_id, |
501 |
message_transport_type => 'email', |
502 |
is_digest => 1 |
503 |
})->store; |
504 |
Koha::Patron::Message::Transport->new({ |
505 |
message_attribute_id => $preference->message_attribute_id, |
506 |
message_transport_type => 'sms', |
507 |
is_digest => 1 |
508 |
})->store; |
509 |
Koha::Patron::Message::Transport->new({ |
510 |
message_attribute_id => $preference->message_attribute_id, |
511 |
message_transport_type => 'phone', |
512 |
is_digest => 1 |
513 |
})->store; |
514 |
Koha::Patron::Message::Transport->new({ |
515 |
message_attribute_id => $preference->message_attribute_id, |
516 |
message_transport_type => 'itiva', |
517 |
is_digest => 1 |
518 |
})->store; |
519 |
$patron->set({ |
520 |
email => 'nobody@koha-community.org', |
521 |
emailpro => 'nobody@koha-community.org', |
522 |
B_email => 'nobody@koha-community.org', |
523 |
smsalertnumber => '123', |
524 |
phone => '123', |
525 |
})->store; |
526 |
t::lib::Mocks::mock_preference('TalkingTechItivaPhoneNotification', 1); |
527 |
|
528 |
is($preference->mtt_deliverable('email'), 1, 'mtt_deliverable - email'); |
529 |
is($preference->mtt_deliverable('itiva'), 1, 'mtt_deliverable - itiva'); |
530 |
is($preference->mtt_deliverable('phone'), 1, 'mtt_deliverable - phone'); |
531 |
is($preference->mtt_deliverable('sms'), 1, 'mtt_deliverable - sms'); |
532 |
|
533 |
$patron->set({email => '',})->store; |
534 |
is($preference->mtt_deliverable('email'), 1, 'mtt_deliverable - emailpro'); |
535 |
|
536 |
$patron->set({emailpro => '',})->store; |
537 |
is($preference->mtt_deliverable('email'), 1, 'mtt_deliverable - B_email'); |
538 |
|
539 |
$patron->set({B_email => '',})->store; |
540 |
is($preference->mtt_deliverable('email'), 0, 'mtt_deliverable - email false'); |
541 |
|
542 |
t::lib::Mocks::mock_preference('TalkingTechItivaPhoneNotification', 0); |
543 |
is($preference->mtt_deliverable('itiva'), 0, 'mtt_deliverable - itiva false'); |
544 |
|
545 |
$patron->set({phone => '',})->store; |
546 |
is($preference->mtt_deliverable('phone'), 0, 'mtt_deliverable - phone false'); |
547 |
|
548 |
$patron->set({smsalertnumber => '',})->store; |
549 |
is($preference->mtt_deliverable('sms'), 0, 'mtt_deliverable - smsalertnumber false'); |
550 |
|
551 |
$schema->storage->txn_rollback; |
552 |
}; |
553 |
|
476 |
subtest 'Test adding a new preference with invalid parameters' => sub { |
554 |
subtest 'Test adding a new preference with invalid parameters' => sub { |
477 |
plan tests => 4; |
555 |
plan tests => 4; |
478 |
|
556 |
|
479 |
- |
|
|