From 23c86c3769407a2387011ac82ee97685f1841d48 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 13 Oct 2016 14:17:13 +0100 Subject: [PATCH] Bug 17425: Add the Object::MethodNotCoveredByTests exception Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- Koha/Exceptions/Object.pm | 6 +++++- Koha/Object.pm | 2 +- t/db_dependent/Koha/Objects.t | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Koha/Exceptions/Object.pm b/Koha/Exceptions/Object.pm index e08b5a5cd0..2ffa1ec851 100644 --- a/Koha/Exceptions/Object.pm +++ b/Koha/Exceptions/Object.pm @@ -14,7 +14,11 @@ use Exception::Class ( 'Koha::Exceptions::Object::PropertyNotFound' => { isa => 'Koha::Exceptions::Object', description => "Invalid property", - } + }, + 'Koha::Exceptions::Object::MethodNotCoveredByTests' => { + isa => 'Koha::Exceptions::Object', + description => "Method not covered by tests", + }, ); 1; diff --git a/Koha/Object.pm b/Koha/Object.pm index cb2b9ef4a4..b5e11af2d7 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -248,7 +248,7 @@ sub AUTOLOAD { my @known_methods = qw( is_changed id in_storage get_column ); - carp "The method $method is not covered by tests or does not exist!" and return unless grep {/^$method$/} @known_methods; + Koha::Exceptions::Object::MethodNotCoveredByTests->throw( "The method $method is not covered by tests!" ) unless grep {/^$method$/} @known_methods; my $r = eval { $self->_result->$method(@_) }; if ( $@ ) { diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index de7b327e0a..de36f54944 100644 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use Test::Warn; use Koha::Authority::Types; @@ -123,8 +123,8 @@ subtest 'Exceptions' => sub { try { $patron->blah('blah'); } catch { - ok( $_->isa('Koha::Exceptions::Object::MethodNotFound'), - 'Calling a non-existent method should raise a Koha::Exceptions::Object::MethodNotFound exception' ); + ok( $_->isa('Koha::Exceptions::Object::MethodNotCoveredByTests'), + 'Calling a non-covered method should raise a Koha::Exceptions::Object::MethodNotCoveredByTests exception' ); }; try { -- 2.20.1