Bug 22343: Add exec flag on .t files
[koha-ffzg.git] / t / Koha / Exceptions.t
old mode 100644 (file)
new mode 100755 (executable)
index a5a504e..13f8304
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 use Test::MockObject;
 use Test::Exception;
 
@@ -115,12 +115,14 @@ subtest 'Koha::Exceptions::Metadata tests' => sub {
     $object->mock( 'schema', 'a_schema' );
 
     throws_ok
-        { Koha::Exceptions::Metadata::Invalid->throw( id => 'an_id', format => 'a_format', schema => 'a_schema' ); }
+        { Koha::Exceptions::Metadata::Invalid->throw(
+            id => 'an_id', format => 'a_format',
+            schema => 'a_schema', decoding_error => 'a_nasty_error' ); }
         'Koha::Exceptions::Metadata::Invalid',
         'Exception is thrown :-D';
 
     # stringify the exception
-    is( "$@", 'Invalid data, cannot decode object (id=an_id, format=a_format, schema=a_schema)', 'Exception stringified correctly' );
+    is( "$@", 'Invalid data, cannot decode object (id=an_id, format=a_format, schema=a_schema, decoding_error=\'a_nasty_error\')', 'Exception stringified correctly' );
 
     throws_ok
         { Koha::Exceptions::Metadata::Invalid->throw( "Manual message exception" ) }
@@ -174,3 +176,23 @@ subtest 'Koha::Exceptions::Patron::Relationship tests' => sub {
         'Exception is thrown :-D';
     is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' );
 };
+
+subtest 'Koha::Exceptions::Object::NotInstantiated tests' => sub {
+
+    plan tests => 4;
+
+    throws_ok
+        { Koha::Exceptions::Object::NotInstantiated->throw(
+            method => 'brain_explode', class => 'Koha::JD' ); }
+        'Koha::Exceptions::Object::NotInstantiated',
+        'Exception is thrown :-D';
+
+    # stringify the exception
+    is( "$@", 'Tried to access the \'brain_explode\' method, but Koha::JD is not instantiated', 'Exception stringified correctly' );
+
+    throws_ok
+        { Koha::Exceptions::Object::NotInstantiated->throw( "Manual message exception" ) }
+        'Koha::Exceptions::Object::NotInstantiated',
+        'Exception is thrown :-D';
+    is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' );
+};