From 48054327a10e2ed6327683f2098f4e4f49c5466b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 4 Oct 2022 12:01:47 +0100 Subject: [PATCH] Bug 25936: (follow-up) Unit test for store This unit test confirms that we are not triggering the Password Change notification notice upon patron creations. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Patrons.t | 36 ++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index ad8e7e58f7..627f0f9f4d 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -1865,7 +1865,7 @@ subtest 'Test Koha::Patrons::merge' => sub { }; subtest '->store' => sub { - plan tests => 7; + plan tests => 8; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; @@ -1921,6 +1921,40 @@ subtest '->store' => sub { is($logs->count, 0, '->store should not have generated a log for updated_on') or diag 'Log generated:'.Dumper($logs->unblessed); $schema->storage->txn_rollback; }; + + subtest 'create user usage' => sub { + plan tests => 1; + $schema->storage->txn_begin; + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron_category = $builder->build_object( + { + class => 'Koha::Patron::Categories', + value => { category_type => 'P', enrolmentfee => 0 } + } + ); + my %data = ( + cardnumber => "123456789", + firstname => "Tômàsító", + surname => "Ñoné", + password => 'Funk3y', + categorycode => $patron_category->categorycode, + branchcode => $library->branchcode, + ); + + # Enable notifying patrons of password changes for these tests + t::lib::Mocks::mock_preference( 'NotifyPasswordChange', 1 ); + my $new_patron = Koha::Patron->new( \%data )->store(); + my $queued_notices = Koha::Notice::Messages->search( + { borrowernumber => $new_patron->borrowernumber } + ); + is( + $queued_notices->count, 0, + "No notice queued when NotifyPasswordChange enabled and this is a new patron" + ); + + $schema->storage->txn_rollback; + }; }; subtest '->set_password' => sub {