|
Lines 200-206
subtest 'Koha::Exceptions::Object::NotInstantiated tests' => sub {
Link Here
|
| 200 |
|
200 |
|
| 201 |
subtest 'Koha::Exceptions::Patron::Attribute::* tests' => sub { |
201 |
subtest 'Koha::Exceptions::Patron::Attribute::* tests' => sub { |
| 202 |
|
202 |
|
| 203 |
plan tests => 5; |
203 |
plan tests => 13; |
| 204 |
|
204 |
|
| 205 |
use_ok("Koha::Exceptions::Patron::Attribute"); |
205 |
use_ok("Koha::Exceptions::Patron::Attribute"); |
| 206 |
|
206 |
|
|
Lines 218-228
subtest 'Koha::Exceptions::Patron::Attribute::* tests' => sub {
Link Here
|
| 218 |
'Exception is thrown :-D'; |
218 |
'Exception is thrown :-D'; |
| 219 |
|
219 |
|
| 220 |
# stringify the exception |
220 |
# stringify the exception |
| 221 |
is( "$@", "Tried to add more than one non-repeatable attributes. code=$code attribute=$attribute", 'Exception stringified correctly' ); |
221 |
is( |
|
|
222 |
"$@", |
| 223 |
"Tried to add more than one non-repeatable attributes. code=$code attribute=$attribute", |
| 224 |
'Exception stringified correctly' |
| 225 |
); |
| 222 |
|
226 |
|
| 223 |
throws_ok |
227 |
throws_ok |
| 224 |
{ Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( "Manual message exception" ) } |
228 |
{ Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( "Manual message exception" ) } |
| 225 |
'Koha::Exceptions::Patron::Attribute::NonRepeatable', |
229 |
'Koha::Exceptions::Patron::Attribute::NonRepeatable', |
| 226 |
'Exception is thrown :-D'; |
230 |
'Exception is thrown :-D'; |
| 227 |
is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' ); |
231 |
|
|
|
232 |
is( |
| 233 |
"$@", |
| 234 |
'Manual message exception', |
| 235 |
'Exception not stringified if manually passed' |
| 236 |
); |
| 237 |
|
| 238 |
throws_ok |
| 239 |
{ Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( |
| 240 |
attribute => $mocked_attribute ); } |
| 241 |
'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint', |
| 242 |
'Exception is thrown :-D'; |
| 243 |
|
| 244 |
# stringify the exception |
| 245 |
is( |
| 246 |
"$@", |
| 247 |
"Your action breaks a unique constraint on the attribute. code=$code attribute=$attribute", |
| 248 |
'Exception stringified correctly' |
| 249 |
); |
| 250 |
|
| 251 |
throws_ok |
| 252 |
{ Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( "Manual message exception" ) } |
| 253 |
'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint', |
| 254 |
'Exception is thrown :-D'; |
| 255 |
|
| 256 |
is( |
| 257 |
"$@", |
| 258 |
'Manual message exception', |
| 259 |
'Exception not stringified if manually passed' |
| 260 |
); |
| 261 |
|
| 262 |
my $type = "SOME_TYPE"; |
| 263 |
|
| 264 |
throws_ok |
| 265 |
{ Koha::Exceptions::Patron::Attribute::InvalidType->throw( |
| 266 |
type => $type ); } |
| 267 |
'Koha::Exceptions::Patron::Attribute::InvalidType', |
| 268 |
'Exception is thrown :-D'; |
| 269 |
|
| 270 |
# stringify the exception |
| 271 |
is( |
| 272 |
"$@", |
| 273 |
"Tried to use an invalid attribute type. type=$type", |
| 274 |
'Exception stringified correctly' |
| 275 |
); |
| 276 |
|
| 277 |
throws_ok |
| 278 |
{ Koha::Exceptions::Patron::Attribute::InvalidType->throw( "Manual message exception" ) } |
| 279 |
'Koha::Exceptions::Patron::Attribute::InvalidType', |
| 280 |
'Exception is thrown :-D'; |
| 281 |
|
| 282 |
is( |
| 283 |
"$@", |
| 284 |
'Manual message exception', |
| 285 |
'Exception not stringified if manually passed' |
| 286 |
); |
| 228 |
}; |
287 |
}; |
| 229 |
- |
|
|