Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 9; |
20 |
use Test::More tests => 10; |
21 |
use Test::MockObject; |
21 |
use Test::MockObject; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
|
23 |
|
Lines 336-338
subtest 'Koha::Exceptions::Plugin tests' => sub {
Link Here
|
336 |
# stringify the exception |
336 |
# stringify the exception |
337 |
is( "$@", "Calling 'upgrade' died for plugin $plugin_class", 'Exception stringified correctly' ); |
337 |
is( "$@", "Calling 'upgrade' died for plugin $plugin_class", 'Exception stringified correctly' ); |
338 |
}; |
338 |
}; |
339 |
- |
339 |
|
|
|
340 |
subtest 'Koha::Exception tests' => sub { |
341 |
|
342 |
plan tests => 8; |
343 |
|
344 |
use Koha::Exception; |
345 |
|
346 |
use Exception::Class ( |
347 |
'Koha::Exceptions::Weird' => { |
348 |
isa => 'Koha::Exception', |
349 |
description => 'Weird exception!', |
350 |
fields => [ 'a', 'b' ] |
351 |
} |
352 |
); |
353 |
|
354 |
my $exception_message = "This is a message"; |
355 |
|
356 |
throws_ok |
357 |
{ Koha::Exceptions::Weird->throw( $exception_message ) } |
358 |
'Koha::Exception', |
359 |
'Exception is thrown :-D'; |
360 |
|
361 |
is( "$@", $exception_message, 'Exception not stringified if manually passed' ); |
362 |
|
363 |
throws_ok |
364 |
{ Koha::Exceptions::Weird->throw( a => "A", b => "B" ) } |
365 |
'Koha::Exception', |
366 |
'Exception is thrown :-D'; |
367 |
|
368 |
is( |
369 |
"$@", |
370 |
"Exception 'Koha::Exceptions::Weird' thrown 'Weird exception!' with a => A, b => B\n", |
371 |
'Exception stringified correctly' |
372 |
); |
373 |
|
374 |
throws_ok |
375 |
{ Koha::Exceptions::Weird->throw( a => "A" ) } |
376 |
'Koha::Exception', |
377 |
'Exception is thrown :-D'; |
378 |
|
379 |
is( |
380 |
"$@", |
381 |
"Exception 'Koha::Exceptions::Weird' thrown 'Weird exception!' with a => A\n", |
382 |
'Exception stringified correctly, b skipped entirely' |
383 |
); |
384 |
|
385 |
throws_ok |
386 |
{ Koha::Exceptions::Weird->throw() } |
387 |
'Koha::Exception', |
388 |
'Exception is thrown :-D'; |
389 |
|
390 |
is( |
391 |
"$@", |
392 |
"Exception 'Koha::Exceptions::Weird' thrown 'Weird exception!'\n", |
393 |
'Exception stringified correctly' |
394 |
); |
395 |
}; |