From c6594e233b93f710c90189b07bda1c54856959b2 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 14 Apr 2021 12:04:19 -0400 Subject: [PATCH] Bug 25183: Add unit tests --- t/db_dependent/Members.t | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t index b7a1ceea15..0499606d2a 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -22,12 +22,14 @@ use Test::MockModule; use Test::Exception; use Data::Dumper qw/Dumper/; + use C4::Context; use Koha::Database; use Koha::Holds; use Koha::List::Patron; -use Koha::Patrons; +use Koha::Old::Patrons; use Koha::Patron::Relationship; +use Koha::Patrons; use t::lib::Mocks; use t::lib::TestBuilder; @@ -401,7 +403,8 @@ $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; ok( $borrower->{userid}, 'A userid should have been generated correctly' ); subtest 'purgeSelfRegistration' => sub { - plan tests => 5; + plan tests => 8; + Koha::Old::Patrons->delete; #purge unverified my $d=360; @@ -449,8 +452,23 @@ subtest 'purgeSelfRegistration' => sub { is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations doesn't delete borrower with fine and no checkout"); $account_line->delete; + is( C4::Members::DeleteExpiredOpacRegistrations('soft'), 1, "DeleteExpiredOpacRegistrations does delete borrower with no fines and no checkouts"); + + is( Koha::Old::Patrons->count, 1, "Patron soft deleted, moved to delete patrons table" ); + Koha::Old::Patrons->delete; + + my $self_reg_2 = $builder->build_object({ + class => 'Koha::Patrons', + value => { + dateenrolled => '2014-01-01 01:02:03', + categorycode => $c + } + }); + is( C4::Members::DeleteExpiredOpacRegistrations(), 1, "DeleteExpiredOpacRegistrations does delete borrower with no fines and no checkouts"); + is( Koha::Old::Patrons->count, 0, "Patron hard deleted, not moved to delete patrons table" ); + }; sub _find_member { -- 2.24.3 (Apple Git-128)