From 4b394f1ba60e6e77c39b1c16cd95e7627a9af17b Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Tue, 28 Apr 2020 11:31:28 -0300
Subject: [PATCH] Bug 25303: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 t/db_dependent/Koha/Objects.t | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t
index c5ac1ba2b6..c81b83358c 100644
--- a/t/db_dependent/Koha/Objects.t
+++ b/t/db_dependent/Koha/Objects.t
@@ -19,8 +19,9 @@
 
 use Modern::Perl;
 
-use Test::More tests => 21;
+use Test::More tests => 22;
 use Test::Exception;
+use Test::MockModule;
 use Test::Warn;
 
 use Koha::Authority::Types;
@@ -799,3 +800,33 @@ subtest 'prefetch_whitelist() tests' => sub {
 
     $schema->storage->txn_rollback;
 };
+
+subtest 'delete() tests' => sub {
+
+    plan tests => 2;
+
+    $schema->storage->txn_begin;
+
+    # Make sure no cities
+    warnings_are { Koha::Cities->delete }[],
+      "No warnings, no Koha::City->delete called as it doesn't exist";
+
+    # Mock Koha::City
+    my $mocked_city = Test::MockModule->new('Koha::City');
+    $mocked_city->mock(
+        'delete',
+        sub {
+            warn "delete called!";
+        }
+    );
+
+    # Add two cities
+    $builder->build_object( { class => 'Koha::Cities' } );
+    $builder->build_object( { class => 'Koha::Cities' } );
+
+    warnings_are { Koha::Cities->delete }
+        [ "delete called!", "delete called!" ],
+        "No warnings, no Koha::City->delete called as it doesn't exist";
+
+    $schema->storage->txn_rollback;
+};
-- 
2.26.2