Lines 94-100
subtest 'Add a test messaging transport' => sub {
Link Here
|
94 |
}; |
94 |
}; |
95 |
|
95 |
|
96 |
subtest 'Add a messaging preference to patron' => sub { |
96 |
subtest 'Add a messaging preference to patron' => sub { |
97 |
plan tests => 2; |
97 |
plan tests => 3; |
98 |
|
98 |
|
99 |
ok($preference = Koha::Patron::Message::Preference->new({ |
99 |
ok($preference = Koha::Patron::Message::Preference->new({ |
100 |
borrowernumber => $patron->{'borrowernumber'}, |
100 |
borrowernumber => $patron->{'borrowernumber'}, |
Lines 105-110
subtest 'Add a messaging preference to patron' => sub {
Link Here
|
105 |
is(Koha::Patron::Message::Preferences->find({ |
105 |
is(Koha::Patron::Message::Preferences->find({ |
106 |
borrowernumber => $patron->{'borrowernumber'} })->message_attribute_id, |
106 |
borrowernumber => $patron->{'borrowernumber'} })->message_attribute_id, |
107 |
$preference->message_attribute_id, "Found test messaging preference from database."); |
107 |
$preference->message_attribute_id, "Found test messaging preference from database."); |
|
|
108 |
subtest 'Attempt to add a messaging preference with invalid parameters' => sub { |
109 |
plan tests => 6; |
110 |
|
111 |
eval { Koha::Patron::Message::Preference->new->store }; |
112 |
is (ref $@, "Koha::Exceptions::MissingParameter", |
113 |
"Adding a message preference without parameters" |
114 |
." => Koha::Exceptions::MissingParameter"); |
115 |
eval { Koha::Patron::Message::Preference->new({ |
116 |
borrowernumber => $patron->{'borrowernumber'}, |
117 |
categorycode => $patron->{'categorycode'}, |
118 |
})->store }; |
119 |
is (ref $@, "Koha::Exceptions::TooManyParameters", |
120 |
"Adding a message preference with both borrowernumber and categorycode" |
121 |
." => Koha::Exceptions::TooManyParameters"); |
122 |
eval { Koha::Patron::Message::Preference->new({ |
123 |
borrowernumber => -999, |
124 |
})->store }; |
125 |
is (ref $@, "Koha::Exceptions::BadParameter", |
126 |
"Adding a message preference with invalid borrowernumber" |
127 |
." => Koha::Exceptions::BadParameter"); |
128 |
is ($@->parameter, "borrowernumber", "The previous exception tells us it" |
129 |
." was the borrowernumber."); |
130 |
eval { Koha::Patron::Message::Preference->new({ |
131 |
categorycode => "nonexistent", |
132 |
})->store }; |
133 |
is (ref $@, "Koha::Exceptions::BadParameter", |
134 |
"Adding a message preference with invalid categorycode" |
135 |
." => Koha::Exceptions::BadParameter"); |
136 |
is ($@->parameter, "categorycode", "The previous exception tells us it" |
137 |
." was the categorycode."); |
138 |
}; |
108 |
}; |
139 |
}; |
109 |
|
140 |
|
110 |
subtest 'Add a messaging transport preference to patron' => sub { |
141 |
subtest 'Add a messaging transport preference to patron' => sub { |
111 |
- |
|
|