Lines 47-52
subtest 'Test Koha::Patron::Message::Preferences' => sub {
Link Here
|
47 |
$schema->storage->txn_begin; |
47 |
$schema->storage->txn_begin; |
48 |
|
48 |
|
49 |
my $attribute = build_a_test_attribute(); |
49 |
my $attribute = build_a_test_attribute(); |
|
|
50 |
my $letter = build_a_test_letter(); |
51 |
my $mtt = build_a_test_transport_type(); |
52 |
Koha::Patron::Message::Transport->new({ |
53 |
message_attribute_id => $attribute->message_attribute_id, |
54 |
message_transport_type => $mtt->message_transport_type, |
55 |
is_digest => 0, |
56 |
letter_module => $letter->module, |
57 |
letter_code => $letter->code, |
58 |
})->store; |
50 |
|
59 |
|
51 |
subtest 'Test for a patron' => sub { |
60 |
subtest 'Test for a patron' => sub { |
52 |
plan tests => 3; |
61 |
plan tests => 3; |
Lines 369-375
subtest 'Test adding a new preference with invalid parameters' => sub {
Link Here
|
369 |
}; |
378 |
}; |
370 |
|
379 |
|
371 |
subtest 'Bad parameter' => sub { |
380 |
subtest 'Bad parameter' => sub { |
372 |
plan tests => 13; |
381 |
plan tests => 19; |
373 |
|
382 |
|
374 |
$schema->storage->txn_begin; |
383 |
$schema->storage->txn_begin; |
375 |
|
384 |
|
Lines 417-423
subtest 'Test adding a new preference with invalid parameters' => sub {
Link Here
|
417 |
.' was the days_in_advance.'); |
426 |
.' was the days_in_advance.'); |
418 |
|
427 |
|
419 |
eval { Koha::Patron::Message::Preference->new({ |
428 |
eval { Koha::Patron::Message::Preference->new({ |
420 |
borrowernumber => $patron->{'borrowernumber'}, |
429 |
borrowernumber => $patron->borrowernumber, |
421 |
message_transport_types => ['nonexistent'] |
430 |
message_transport_types => ['nonexistent'] |
422 |
})->store }; |
431 |
})->store }; |
423 |
is (ref $@, 'Koha::Exceptions::BadParameter', |
432 |
is (ref $@, 'Koha::Exceptions::BadParameter', |
Lines 427-433
subtest 'Test adding a new preference with invalid parameters' => sub {
Link Here
|
427 |
.' was the message_transport_type.'); |
436 |
.' was the message_transport_type.'); |
428 |
eval { |
437 |
eval { |
429 |
Koha::Patron::Message::Preference->new({ |
438 |
Koha::Patron::Message::Preference->new({ |
430 |
borrowernumber => $patron->{'borrowernumber'}, |
439 |
borrowernumber => $patron->borrowernumber, |
431 |
message_attribute_id => $attribute->message_attribute_id, |
440 |
message_attribute_id => $attribute->message_attribute_id, |
432 |
message_transport_types => ['sms'], |
441 |
message_transport_types => ['sms'], |
433 |
wants_digest => 1, |
442 |
wants_digest => 1, |
Lines 440-445
subtest 'Test adding a new preference with invalid parameters' => sub {
Link Here
|
440 |
like ($@->error, qr/^Message transport option/, 'Exception s because of given' |
449 |
like ($@->error, qr/^Message transport option/, 'Exception s because of given' |
441 |
.' message_transport_type is not a valid option.'); |
450 |
.' message_transport_type is not a valid option.'); |
442 |
|
451 |
|
|
|
452 |
eval { |
453 |
Koha::Patron::Message::Preference->new({ |
454 |
borrowernumber => $patron->borrowernumber, |
455 |
message_attribute_id => $attribute->message_attribute_id, |
456 |
message_transport_types => [], |
457 |
wants_digest => 1, |
458 |
})->store }; |
459 |
is (ref $@, 'Koha::Exceptions::BadParameter', |
460 |
'Adding a message preference with invalid message_transport_type' |
461 |
.' => Koha::Exceptions::BadParameter'); |
462 |
is ($@->parameter, 'wants_digest', 'The previous exception tells us it' |
463 |
.' was the wants_digest'); |
464 |
like ($@->error, qr/^Digest not available/, 'Exception s because of given' |
465 |
.' digest is not available for this transport.'); |
466 |
|
467 |
eval { |
468 |
Koha::Patron::Message::Preference->new({ |
469 |
borrowernumber => $patron->borrowernumber, |
470 |
message_attribute_id => -1, |
471 |
message_transport_types => [], |
472 |
})->store }; |
473 |
is (ref $@, 'Koha::Exceptions::BadParameter', |
474 |
'Adding a message preference with invalid message_transport_type' |
475 |
.' => Koha::Exceptions::BadParameter'); |
476 |
is ($@->parameter, 'message_attribute_id', 'The previous exception tells' |
477 |
.' us it was the message_attribute_id'); |
478 |
like ($@->error, qr/^Message attribute with id -1 not found/, 'Exception ' |
479 |
.' is because of given message attribute id is not found.'); |
480 |
|
443 |
$schema->storage->txn_rollback; |
481 |
$schema->storage->txn_rollback; |
444 |
}; |
482 |
}; |
445 |
|
483 |
|
Lines 449-454
subtest 'Test adding a new preference with invalid parameters' => sub {
Link Here
|
449 |
$schema->storage->txn_begin; |
487 |
$schema->storage->txn_begin; |
450 |
|
488 |
|
451 |
my $attribute = build_a_test_attribute(); |
489 |
my $attribute = build_a_test_attribute(); |
|
|
490 |
my $letter = build_a_test_letter(); |
491 |
my $mtt = build_a_test_transport_type(); |
492 |
Koha::Patron::Message::Transport->new({ |
493 |
message_attribute_id => $attribute->message_attribute_id, |
494 |
message_transport_type => $mtt->message_transport_type, |
495 |
is_digest => 0, |
496 |
letter_module => $letter->module, |
497 |
letter_code => $letter->code, |
498 |
})->store; |
452 |
my $patron = build_a_test_patron(); |
499 |
my $patron = build_a_test_patron(); |
453 |
my $preference = Koha::Patron::Message::Preference->new({ |
500 |
my $preference = Koha::Patron::Message::Preference->new({ |
454 |
borrowernumber => $patron->borrowernumber, |
501 |
borrowernumber => $patron->borrowernumber, |
Lines 570-576
sub build_a_test_category_preference {
Link Here
|
570 |
message_attribute_id => $attr->message_attribute_id, |
617 |
message_attribute_id => $attr->message_attribute_id, |
571 |
wants_digest => $params->{digest} ? 1 : 0, |
618 |
wants_digest => $params->{digest} ? 1 : 0, |
572 |
days_in_advance => $params->{days_in_advance} |
619 |
days_in_advance => $params->{days_in_advance} |
573 |
? $params->{days_in_advance} : 0, |
620 |
? $params->{days_in_advance} : undef, |
574 |
})->store; |
621 |
})->store; |
575 |
|
622 |
|
576 |
Koha::Patron::Message::Transport::Preference->new({ |
623 |
Koha::Patron::Message::Transport::Preference->new({ |
577 |
- |
|
|