Bug 17425: Add the Object::MethodNotCoveredByTests exception
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 13 Oct 2016 13:17:13 +0000 (14:17 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 21 Oct 2016 17:38:26 +0000 (17:38 +0000)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Koha/Exceptions/Object.pm
Koha/Object.pm
t/db_dependent/Koha/Objects.t

index e08b5a5..2ffa1ec 100644 (file)
@@ -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;
index cb2b9ef..b5e11af 100644 (file)
@@ -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 ( $@ ) {
index de7b327..de36f54 100644 (file)
@@ -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 {