Bug 23825: Add tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 24 Oct 2019 10:51:19 +0000 (12:51 +0200)
committerVictor Grousset/tuxayo <victor@tuxayo.net>
Mon, 22 Jun 2020 23:13:07 +0000 (01:13 +0200)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
[EDIT]
Changed 'is' to 'like' with regex since we also have the db name.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

(cherry picked from commit 6a2c5d665e67bdc050c44030cc75ca732970f9da)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

t/db_dependent/Koha/Object.t

index 3556f6e..1f4d316 100755 (executable)
@@ -347,17 +347,20 @@ subtest 'store() tests' => sub {
 
     subtest 'Bad value tests' => sub {
 
-        plan tests => 1;
+        plan tests => 3;
 
         my $patron = $builder->build_object({ class => 'Koha::Patrons' });
 
         my $print_error = $schema->storage->dbh->{PrintError};
         $schema->storage->dbh->{PrintError} = 0;
 
-        throws_ok
-            { $patron->lastseen('wrong_value')->store; }
-            'Koha::Exceptions::Object::BadValue',
-            'Exception thrown correctly';
+        try {
+            $patron->lastseen('wrong_value')->store;
+        } catch {
+            ok( $_->isa('Koha::Exceptions::Object::BadValue'), 'Exception thrown correctly' );
+            like( $_->property, qr/borrowers\W?\.\W?lastseen/, 'Column should be the expected one' ); # optional \W for quote or backtic
+            is( $_->value, 'wrong_value', 'Value should be the expected one' );
+        };
 
         $schema->storage->dbh->{PrintError} = $print_error;
     };