Bug 40608: (follow-up) Some tests rely on existing data

Playing with the about page, I noticed prior tests in the codebase fail
if the letter doesn't exist.

This patch fixes that.

To test:
1. With a fresh KTD run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Patron.t
=> SUCCESS: Tests pass!
2. Delete the existing notices:
  k$ koha-mysql kohadev
   > DELETE FROM letter WHERE code="PASSWORD_CHANGE"; \q
3. Repeat 1
=> FAIL: Tests fail! Current tests print a warn (Test::NoWarning)
doesn't like this
4. Apply this patch
5. Repeat 1
=> SUCCESS: Tests now pass. The test creates its own notice.
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 93a830b8ca)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Tomas Cohen Arazi 2025-08-07 16:18:39 -03:00 committed by Paul Derscheid
parent a6b22a27dd
commit ab0fa4fea6
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 18 additions and 0 deletions

View File

@ -1555,6 +1555,24 @@ subtest 'password expiration tests' => sub {
}
}
);
# Create a PASSWORD_CHANGE letter template
$builder->build_object(
{
class => 'Koha::Notice::Templates',
value => {
module => 'members',
code => 'PASSWORD_CHANGE',
branchcode => '',
name => 'Password Change Notification',
is_html => 0,
title => 'Your password has been changed',
content => 'Dear [% borrower.firstname %], your password has been changed.',
message_transport_type => 'email',
lang => 'default'
}
}
);
is( $patron->password_expired, 1, "Patron password is expired" );
$date = dt_from_string();