Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 15; |
22 |
use Test::More tests => 16; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Test::Warn; |
24 |
use Test::Warn; |
25 |
|
25 |
|
Lines 1107-1109
subtest 'recalls() tests' => sub {
Link Here
|
1107 |
|
1107 |
|
1108 |
$schema->storage->txn_rollback; |
1108 |
$schema->storage->txn_rollback; |
1109 |
}; |
1109 |
}; |
1110 |
- |
1110 |
|
|
|
1111 |
subtest 'notify_library_of_registration()' => sub { |
1112 |
|
1113 |
plan tests => 6; |
1114 |
|
1115 |
$schema->storage->txn_begin; |
1116 |
my $dbh = C4::Context->dbh; |
1117 |
|
1118 |
my $library = $builder->build_object( |
1119 |
{ |
1120 |
class => 'Koha::Libraries', |
1121 |
value => { |
1122 |
branchemail => 'from@mybranch.com', |
1123 |
branchreplyto => 'to@mybranch.com' |
1124 |
} |
1125 |
} |
1126 |
); |
1127 |
my $patron = $builder->build_object( |
1128 |
{ |
1129 |
class => 'Koha::Patrons', |
1130 |
value => { |
1131 |
branchcode => $library->branchcode |
1132 |
} |
1133 |
} |
1134 |
); |
1135 |
|
1136 |
t::lib::Mocks::mock_preference( 'KohaAdminEmailAddress', 'root@localhost' ); |
1137 |
t::lib::Mocks::mock_preference( 'EmailAddressForPatronRegistrations', 'library@localhost' ); |
1138 |
|
1139 |
# Test when EmailPatronRegistrations equals BranchEmailAddress |
1140 |
t::lib::Mocks::mock_preference( 'EmailPatronRegistrations', 'BranchEmailAddress' ); |
1141 |
is( $patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')), 1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals BranchEmailAddress'); |
1142 |
my $sth = $dbh->prepare("SELECT to_address FROM message_queue where borrowernumber = ?"); |
1143 |
$sth->execute( $patron->borrowernumber ); |
1144 |
my $to_address = $sth->fetchrow_array; |
1145 |
is( $to_address, 'to@mybranch.com', 'OPAC_REG email queued to go to branchreplyto address when EmailPatronRegistration equals BranchEmailAddress' ); |
1146 |
$dbh->do(q|DELETE FROM message_queue|); |
1147 |
|
1148 |
# Test when EmailPatronRegistrations equals EmailAddressForPatronRegistrations |
1149 |
t::lib::Mocks::mock_preference( 'EmailPatronRegistrations', 'EmailAddressForPatronRegistrations' ); |
1150 |
is( $patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')), 1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals EmailAddressForPatronRegistrations'); |
1151 |
$sth->execute( $patron->borrowernumber ); |
1152 |
$to_address = $sth->fetchrow_array; |
1153 |
is( $to_address, 'library@localhost', 'OPAC_REG email queued to go to EmailAddressForPatronRegistrations syspref when EmailPatronRegistration equals EmailAddressForPatronRegistrations' ); |
1154 |
$dbh->do(q|DELETE FROM message_queue|); |
1155 |
|
1156 |
# Test when EmailPatronRegistrations equals KohaAdminEmailAddress |
1157 |
t::lib::Mocks::mock_preference( 'EmailPatronRegistrations', 'KohaAdminEmailAddress' ); |
1158 |
is( $patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')), 1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals KohaAdminEmailAddress'); |
1159 |
$sth->execute( $patron->borrowernumber ); |
1160 |
$to_address = $sth->fetchrow_array; |
1161 |
is( $to_address, 'root@localhost', 'OPAC_REG email queued to go to KohaAdminEmailAddress syspref when EmailPatronRegistration equals KohaAdminEmailAddress' ); |
1162 |
$dbh->do(q|DELETE FROM message_queue|); |
1163 |
|
1164 |
$schema->storage->txn_rollback; |
1165 |
}; |
1166 |
|