Bug 22052: Unit tests

Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit f44e37b201)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2018-12-28 18:48:15 +00:00 committed by Martin Renvoize
parent 03e6ecd31c
commit 2bc4f25855
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 32 additions and 3 deletions

View File

@ -337,7 +337,7 @@ $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
ok( $borrower->{userid}, 'A userid should have been generated correctly' );
subtest 'purgeSelfRegistration' => sub {
plan tests => 2;
plan tests => 5;
#purge unverified
my $d=360;
@ -353,8 +353,37 @@ subtest 'purgeSelfRegistration' => sub {
t::lib::Mocks::mock_preference('PatronSelfRegistrationDefaultCategory', $c );
t::lib::Mocks::mock_preference('PatronSelfRegistrationExpireTemporaryAccountsDelay', 360);
C4::Members::DeleteExpiredOpacRegistrations();
$dbh->do("INSERT INTO borrowers (surname, address, city, branchcode, categorycode, dateenrolled) VALUES ('Testaabbcc', 'Street 1', 'CITY', ?, '$c', '2014-01-01 01:02:03')", undef, $library1->{branchcode});
is( C4::Members::DeleteExpiredOpacRegistrations(), 1, 'Test for DeleteExpiredOpacRegistrations');
my $self_reg = $builder->build_object({
class => 'Koha::Patrons',
value => {
dateenrolled => '2014-01-01 01:02:03',
categorycode => $c
}
});
my $checkout = $builder->build_object({
class=>'Koha::Checkouts',
value=>{
borrowernumber=>$self_reg->borrowernumber
}
});
is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations doesn't delete borrower with checkout");
my $account_line = $builder->build_object({
class=>'Koha::Account::Lines',
value=>{
borrowernumber=>$self_reg->borrowernumber,
amountoutstanding=>5
}
});
is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations doesn't delete borrower with checkout and fine");
$checkout->delete;
is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations doesn't delete borrower with fine and no checkout");
$account_line->delete;
is( C4::Members::DeleteExpiredOpacRegistrations(), 1, "DeleteExpiredOpacRegistrations does delete borrower with no fines and no checkouts");
};
sub _find_member {