Bugzilla – Attachment 138239 Details for
Bug 23538
Email library when new patrons self register
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23538: Unit tests
Bug-23538-Unit-tests.patch (text/plain), 3.82 KB, created by
David Nind
on 2022-07-28 22:47:44 UTC
(
hide
)
Description:
Bug 23538: Unit tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-07-28 22:47:44 UTC
Size:
3.82 KB
patch
obsolete
>From c717151602b2634a928278e9f99cce6a9d05e679 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 6 Apr 2022 10:38:38 +0000 >Subject: [PATCH] Bug 23538: Unit tests > >Test plan: >1. Run unit tests: >sudo koha-shell <instance> >cd t/db_dependent/Koha >prove -v Patron.t > >Sponsored-by: Catalyst IT > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/Patron.t | 58 +++++++++++++++++++++++++++++++++++- > 1 file changed, 57 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 977ec261d6..fa035b8c04 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 18; >+use Test::More tests => 19; > use Test::Exception; > use Test::Warn; > >@@ -1292,3 +1292,59 @@ subtest 'encode_secret and decoded_secret' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'notify_library_of_registration()' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ my $dbh = C4::Context->dbh; >+ >+ my $library = $builder->build_object( >+ { >+ class => 'Koha::Libraries', >+ value => { >+ branchemail => 'from@mybranch.com', >+ branchreplyto => 'to@mybranch.com' >+ } >+ } >+ ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ branchcode => $library->branchcode >+ } >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'KohaAdminEmailAddress', 'root@localhost' ); >+ t::lib::Mocks::mock_preference( 'EmailAddressForPatronRegistrations', 'library@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@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@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@localhost', 'OPAC_REG email queued to go to KohaAdminEmailAddress syspref when EmailPatronRegistration equals KohaAdminEmailAddress' ); >+ $dbh->do(q|DELETE FROM message_queue|); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23538
:
133050
|
133051
|
133052
|
133053
|
133097
|
133098
|
133099
|
133100
|
133101
|
133102
|
133103
|
137997
|
137998
|
137999
|
138000
|
138001
|
138237
|
138238
|
138239
|
138240
|
138383
|
138384
|
138385
|
138386
|
138387
|
141223