From a236eb64c78be6577865bb10d1978c19809818ab Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 30 Mar 2021 10:51:34 -0300 Subject: [PATCH] Bug 28056: Unit tests --- t/Koha/Exceptions.t | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/t/Koha/Exceptions.t b/t/Koha/Exceptions.t index 908f6546a89..3ffb34b2995 100755 --- a/t/Koha/Exceptions.t +++ b/t/Koha/Exceptions.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 7; +use Test::More tests => 8; use Test::MockObject; use Test::Exception; @@ -285,3 +285,27 @@ subtest 'Koha::Exceptions::Patron::Attribute::* tests' => sub { 'Exception not stringified if manually passed' ); }; + +subtest 'Koha::Exceptions::Patron tests' => sub { + + plan tests => 5; + + use_ok("Koha::Exceptions::Patron"); + + my $type = 'yahey'; + + throws_ok + { Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw( + type => $type ); } + 'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute', + 'Exception is thrown :-D'; + + # stringify the exception + is( "$@", "Missing mandatory extended attribute (type=$type)", 'Exception stringified correctly' ); + + throws_ok + { Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw( "Manual message exception" ) } + 'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute', + 'Exception is thrown :-D'; + is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' ); +}; -- 2.31.1