Lines 126-132
subtest 'Add a test messaging transport' => sub {
Link Here
|
126 |
}; |
126 |
}; |
127 |
|
127 |
|
128 |
subtest 'Add a messaging preference to patron' => sub { |
128 |
subtest 'Add a messaging preference to patron' => sub { |
129 |
plan tests => 4; |
129 |
plan tests => 5; |
130 |
|
130 |
|
131 |
ok($preference = Koha::Patron::Message::Preference->new({ |
131 |
ok($preference = Koha::Patron::Message::Preference->new({ |
132 |
borrowernumber => $patron->{'borrowernumber'}, |
132 |
borrowernumber => $patron->{'borrowernumber'}, |
Lines 147-152
subtest 'Add a messaging preference to patron' => sub {
Link Here
|
147 |
"Adding a duplicate preference" |
147 |
"Adding a duplicate preference" |
148 |
." => Koha::Exceptions::DuplicateObject"); |
148 |
." => Koha::Exceptions::DuplicateObject"); |
149 |
|
149 |
|
|
|
150 |
subtest 'Add preferences from defaults' => sub { |
151 |
plan tests => 4; |
152 |
|
153 |
my $attr = Koha::Patron::Message::Attribute->new({ |
154 |
message_name => "default", |
155 |
})->store; |
156 |
ok(my $default = Koha::Patron::Message::Preference->new({ |
157 |
categorycode => $patron->{'categorycode'}, |
158 |
message_attribute_id => $attr->message_attribute_id, |
159 |
wants_digest => 1, |
160 |
days_in_advance => 1337, |
161 |
})->store, "Created a new default preference for category."); |
162 |
Koha::Patron::Message::Transport::Preference->new({ |
163 |
borrower_message_preference_id => $default->borrower_message_preference_id, |
164 |
message_transport_type => "sms", |
165 |
})->store; |
166 |
Koha::Patron::Message::Transport::Preference->new({ |
167 |
borrower_message_preference_id => $default->borrower_message_preference_id, |
168 |
message_transport_type => "email", |
169 |
})->store; |
170 |
ok(Koha::Patron::Message::Preference->new_from_default({ |
171 |
borrowernumber => $patron->{'borrowernumber'}, |
172 |
categorycode => $patron->{'categorycode'}, |
173 |
message_attribute_id => $attr->message_attribute_id, |
174 |
})->store, "Added a default preference to patron."); |
175 |
ok(my $pref = Koha::Patron::Message::Preferences->find({ |
176 |
borrowernumber => $patron->{'borrowernumber'}, |
177 |
message_attribute_id => $attr->message_attribute_id, |
178 |
}), "Found the default preference from patron."); |
179 |
is(Koha::Patron::Message::Transport::Preferences->search({ |
180 |
borrower_message_preference_id => $pref->borrower_message_preference_id |
181 |
})->count, 2, "Found the two transport types that we set earlier"); |
182 |
}; |
183 |
|
150 |
subtest 'Attempt to add a messaging preference with invalid parameters' => sub { |
184 |
subtest 'Attempt to add a messaging preference with invalid parameters' => sub { |
151 |
plan tests => 6; |
185 |
plan tests => 6; |
152 |
|
186 |
|
153 |
- |
|
|