From 4d682c3c5d5bf48dabfd271123dc40279488e320 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatetsolutions.com>
Date: Fri, 9 Mar 2018 09:51:52 -0500
Subject: [PATCH] Bug 18626: Add unit tests

---
 t/db_dependent/Koha/Patrons.t | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t
index 2323d21..451bd79 100644
--- a/t/db_dependent/Koha/Patrons.t
+++ b/t/db_dependent/Koha/Patrons.t
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 25;
+use Test::More tests => 26;
 use Test::Warn;
 use Time::Fake;
 use DateTime;
@@ -1121,6 +1121,20 @@ subtest 'is_child | is_adult' => sub {
 $retrieved_patron_1->delete;
 is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
 
+subtest 'Log cardnumber change' => sub {
+    plan tests => 1;
+
+    t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
+    my $patron = $builder->build( { source => 'Borrower' } );
+
+    $patron->{cardnumber} = 'TESTCARDNUMBER';
+    ModMember(%$patron);
+
+    my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'MODIFY', object => $patron->{borrowernumber} } )->count;
+    is( $number_of_logs, 2, 'With BorrowerLogs, Change in cardnumbder should be logged.' );
+};
+
+
 $schema->storage->txn_rollback;
 
 # TODO Move to t::lib::Mocks and reuse it!
-- 
2.10.2