From 9614979986e33067ebc5b4ca13668d360ef015a6 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 28 Dec 2018 12:15:36 -0300 Subject: [PATCH] Bug 22051: Unit tests --- t/db_dependent/Koha/Object.t | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index e1812bc1c6..e6ad3c3254 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -241,7 +241,7 @@ subtest "Test update method" => sub { subtest 'store() tests' => sub { - plan tests => 7; + plan tests => 8; # Using Koha::ApiKey to test Koha::Object>-store # Simple object with foreign keys and unique key @@ -305,6 +305,23 @@ subtest 'store() tests' => sub { my $ret = $api_key->store; is( ref($ret), 'Koha::ApiKey', 'store() returns the object on success' ); + subtest 'Bad value tests' => sub { + + plan tests => 1; + + 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'; + + $schema->storage->dbh->{PrintError} = $print_error; + }; + $schema->storage->txn_rollback; }; -- 2.20.1