View | Details | Raw Unified | Return to bug 29857
Collapse All | Expand All

(-)a/t/Koha/Exceptions.t (-2 / +48 lines)
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 => 6;
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
364
    throws_ok
365
        { Koha::Exceptions::Weird->throw( a => "A", b => "B" ) }
366
        'Koha::Exception',
367
        'Exception is thrown :-D';
368
369
    is(
370
        "$@",
371
        "Exception 'Koha::Exceptions::Weird' thrown 'Weird exception!' with a => A, b => B\n",
372
        'Exception stringified correctly'
373
    );
374
375
    throws_ok
376
        { Koha::Exceptions::Weird->throw() }
377
        'Koha::Exception',
378
        'Exception is thrown :-D';
379
380
    is(
381
        "$@",
382
        "Exception 'Koha::Exceptions::Weird' thrown 'Weird exception!'\n",
383
        'Exception not stringified if manually passed'
384
    );
385
};

Return to bug 29857