[Koha-bugs] [Bug 23538] Email library when new patrons self register

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Oct 3 09:12:10 CEST 2022


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23538

Marcel de Rooy <m.de.rooy at rijksmuseum.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m.de.rooy at rijksmuseum.nl

--- Comment #36 from Marcel de Rooy <m.de.rooy at rijksmuseum.nl> ---
+    t::lib::Mocks::mock_preference( 'KohaAdminEmailAddress', 'root at localhost'
);
+    t::lib::Mocks::mock_preference( 'EmailAddressForPatronRegistrations',
'library at localhost' );
+
+    # Test when EmailPatronRegistrations equals BranchEmailAddress
+    t::lib::Mocks::mock_preference( 'EmailPatronRegistrations',
'BranchEmailAddress' );
+    is(
$patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')),
1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals
BranchEmailAddress');
+    my $sth = $dbh->prepare("SELECT to_address FROM message_queue where
borrowernumber = ?");
+    $sth->execute( $patron->borrowernumber );
+    my $to_address = $sth->fetchrow_array;
+    is( $to_address, 'to at mybranch.com', 'OPAC_REG email queued to go to
branchreplyto address when EmailPatronRegistration equals BranchEmailAddress'
);
+    $dbh->do(q|DELETE FROM message_queue|);
+
+    # Test when EmailPatronRegistrations equals
EmailAddressForPatronRegistrations
+    t::lib::Mocks::mock_preference( 'EmailPatronRegistrations',
'EmailAddressForPatronRegistrations' );
+    is(
$patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')),
1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals
EmailAddressForPatronRegistrations');
+    $sth->execute( $patron->borrowernumber );
+    $to_address = $sth->fetchrow_array;
+    is( $to_address, 'library at localhost', 'OPAC_REG email queued to go to
EmailAddressForPatronRegistrations syspref when EmailPatronRegistration equals
EmailAddressForPatronRegistrations' );
+    $dbh->do(q|DELETE FROM message_queue|);
+
+    # Test when EmailPatronRegistrations equals KohaAdminEmailAddress
+    t::lib::Mocks::mock_preference( 'EmailPatronRegistrations',
'KohaAdminEmailAddress' );
+    is(
$patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')),
1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals
KohaAdminEmailAddress');
+    $sth->execute( $patron->borrowernumber );
+    $to_address = $sth->fetchrow_array;
+    is( $to_address, 'root at localhost', 'OPAC_REG email queued to go to
KohaAdminEmailAddress syspref when EmailPatronRegistration equals
KohaAdminEmailAddress' );
+    $dbh->do(q|DELETE FROM message_queue|);

This part of the test fails with me:
    not ok 6 - OPAC_REG email queued to go to KohaAdminEmailAddress syspref
when EmailPatronRegistration equals KohaAdminEmailAddress
    #   Failed test 'OPAC_REG email queued to go to KohaAdminEmailAddress
syspref when EmailPatronRegistration equals KohaAdminEmailAddress'
    #   at t/db_dependent/Koha/Patron.t line 1347.
    #          got: 'bibliotheek at master.rijkskoha.nl'
    #     expected: 'root at localhost'
    # Looks like you failed 1 test of 6.

Also note that you'd better not use localhost as an email address in your
tests. 
And that you include several SQL statements that should be Koha objects.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list