From c7e69ded75c8ffecd7b283e0fedf6e10c54ec0e4 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 8 May 2020 08:47:25 -0300 Subject: [PATCH] Bug 25423: Unit tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Objects.t | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index 96a6bc6d30..09d18b210a 100644 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -772,7 +772,7 @@ subtest 'Return same values as DBIx::Class' => sub { subtest 'Koha::Objects->update' => sub { - plan tests => 4; + plan tests => 6; my ( $r_us, $e_us, $r_them, $e_them ); @@ -853,6 +853,14 @@ subtest 'Return same values as DBIx::Class' => sub { ok( $r_us == 2 && $r_them == 2, '->update should return the number of updated cities' ); ok(!defined($e_us) && !defined($e_them)); + + throws_ok + { Koha::Cities->update({ city_country => 'Castalia' }); } + 'Koha::Exceptions::Object::NotInstantiated', + 'Exception thrown if not instantiated class'; + + is( "$@", 'Tried to access the \'update\' method, but Koha::Patrons is not instantiated', 'Exception stringified correctly' ); + }; }; @@ -1090,9 +1098,12 @@ subtest 'empty() tests' => sub { is( ref($empty), 'Koha::Patrons', '->empty returns a Koha::Patrons iterator' ); is( $empty->count, 0, 'The empty resultset is, well, empty :-D' ); - $empty = Koha::Patrons->empty; - is( ref($empty), 'Koha::Patrons', 'without being instantiated, ->empty still returns a Koha::Patrons iterator' ); - is( $empty->count, 0, 'The empty resultset is, well, empty :-D' ); + throws_ok + { Koha::Patrons->empty; } + 'Koha::Exceptions::Object::NotInstantiated', + 'Exception thrown if not instantiated class'; + + is( "$@", 'Tried to access the \'empty\' method, but Koha::Patrons is not instantiated', 'Exception stringified correctly' ); $schema->storage->txn_rollback; }; -- 2.20.1