From 4bfd14171a9f36c8037110d33520a1b40f94788e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 7 Aug 2025 16:18:39 -0300 Subject: [PATCH] Bug 40608: (follow-up) Some tests rely on existing data Content-Type: text/plain; charset=utf-8 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 Signed-off-by: Marcel de Rooy --- t/db_dependent/Koha/Patron.t | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index 6d04931935..d2d8182c81 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -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(); -- 2.39.5