|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 15; |
22 |
use Test::More tests => 16; |
| 23 |
|
23 |
|
| 24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
| 25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
|
Lines 56-61
my $preference;
Link Here
|
| 56 |
my $transport_preference; |
56 |
my $transport_preference; |
| 57 |
my $transport_type; |
57 |
my $transport_type; |
| 58 |
|
58 |
|
|
|
59 |
subtest 'Test Koha::Patron::Message::Preferences->get_options' => sub { |
| 60 |
plan tests => 5; |
| 61 |
|
| 62 |
ok(Koha::Patron::Message::Preferences->can('get_options'), |
| 63 |
"Method get_options is available"); |
| 64 |
ok(my $options = Koha::Patron::Message::Preferences->get_options, |
| 65 |
"Called get_options successfully"); |
| 66 |
is(ref $options, "ARRAY", "get_options returns a HASHref"); |
| 67 |
my $message_attributes = Koha::Patron::Message::Attributes->search; |
| 68 |
is(@$options, $message_attributes->count, "There are equal amount of" |
| 69 |
." options and message attributes"); |
| 70 |
|
| 71 |
subtest 'Make sure options are correct' => sub { |
| 72 |
foreach my $option (@$options) { |
| 73 |
my $n = $option->{'message_name'}; |
| 74 |
my $attr = Koha::Patron::Message::Attributes->find($option->{'message_attribute_id'}); |
| 75 |
is($option->{'message_attribute_id'}, $attr->message_attribute_id, |
| 76 |
"$n: message_attribute_id is set"); |
| 77 |
is($option->{'message_name'}, $attr->message_name, "$n: message_name is set"); |
| 78 |
is($option->{'takes_days'}, $attr->takes_days, "$n: takes_days is set"); |
| 79 |
my $transports = Koha::Patron::Message::Transports->search({ |
| 80 |
message_attribute_id => $option->{'message_attribute_id'}, |
| 81 |
is_digest => $option->{'has_digest'} || 0, |
| 82 |
}); |
| 83 |
while (my $trnzport = $transports->next) { |
| 84 |
is($option->{'has_digest'} || 0, $trnzport->is_digest, "$n: has_digest is set for ".$trnzport->message_transport_type); |
| 85 |
is($option->{'transport_'.$trnzport->message_transport_type}, ' ', "$n: transport_".$trnzport->message_transport_type." is set"); |
| 86 |
} |
| 87 |
} |
| 88 |
}; |
| 89 |
}; |
| 90 |
|
| 59 |
subtest 'Add a test messaging transport type' => sub { |
91 |
subtest 'Add a test messaging transport type' => sub { |
| 60 |
plan tests => 2; |
92 |
plan tests => 2; |
| 61 |
|
93 |
|
| 62 |
- |
|
|