Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 18; |
22 |
use Test::More tests => 19; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Test::Warn; |
24 |
use Test::Warn; |
25 |
|
25 |
|
Lines 1292-1294
subtest 'encode_secret and decoded_secret' => sub {
Link Here
|
1292 |
|
1292 |
|
1293 |
$schema->storage->txn_rollback; |
1293 |
$schema->storage->txn_rollback; |
1294 |
}; |
1294 |
}; |
1295 |
- |
1295 |
|
|
|
1296 |
subtest 'notify_library_of_registration()' => sub { |
1297 |
|
1298 |
plan tests => 6; |
1299 |
|
1300 |
$schema->storage->txn_begin; |
1301 |
my $dbh = C4::Context->dbh; |
1302 |
|
1303 |
my $library = $builder->build_object( |
1304 |
{ |
1305 |
class => 'Koha::Libraries', |
1306 |
value => { |
1307 |
branchemail => 'from@mybranch.com', |
1308 |
branchreplyto => 'to@mybranch.com' |
1309 |
} |
1310 |
} |
1311 |
); |
1312 |
my $patron = $builder->build_object( |
1313 |
{ |
1314 |
class => 'Koha::Patrons', |
1315 |
value => { |
1316 |
branchcode => $library->branchcode |
1317 |
} |
1318 |
} |
1319 |
); |
1320 |
|
1321 |
t::lib::Mocks::mock_preference( 'KohaAdminEmailAddress', 'root@localhost' ); |
1322 |
t::lib::Mocks::mock_preference( 'EmailAddressForPatronRegistrations', 'library@localhost' ); |
1323 |
|
1324 |
# Test when EmailPatronRegistrations equals BranchEmailAddress |
1325 |
t::lib::Mocks::mock_preference( 'EmailPatronRegistrations', 'BranchEmailAddress' ); |
1326 |
is( $patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')), 1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals BranchEmailAddress'); |
1327 |
my $sth = $dbh->prepare("SELECT to_address FROM message_queue where borrowernumber = ?"); |
1328 |
$sth->execute( $patron->borrowernumber ); |
1329 |
my $to_address = $sth->fetchrow_array; |
1330 |
is( $to_address, 'to@mybranch.com', 'OPAC_REG email queued to go to branchreplyto address when EmailPatronRegistration equals BranchEmailAddress' ); |
1331 |
$dbh->do(q|DELETE FROM message_queue|); |
1332 |
|
1333 |
# Test when EmailPatronRegistrations equals EmailAddressForPatronRegistrations |
1334 |
t::lib::Mocks::mock_preference( 'EmailPatronRegistrations', 'EmailAddressForPatronRegistrations' ); |
1335 |
is( $patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')), 1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals EmailAddressForPatronRegistrations'); |
1336 |
$sth->execute( $patron->borrowernumber ); |
1337 |
$to_address = $sth->fetchrow_array; |
1338 |
is( $to_address, 'library@localhost', 'OPAC_REG email queued to go to EmailAddressForPatronRegistrations syspref when EmailPatronRegistration equals EmailAddressForPatronRegistrations' ); |
1339 |
$dbh->do(q|DELETE FROM message_queue|); |
1340 |
|
1341 |
# Test when EmailPatronRegistrations equals KohaAdminEmailAddress |
1342 |
t::lib::Mocks::mock_preference( 'EmailPatronRegistrations', 'KohaAdminEmailAddress' ); |
1343 |
is( $patron->notify_library_of_registration(C4::Context->preference('EmailPatronRegistrations')), 1, 'OPAC_REG email is queued if EmailPatronRegistration syspref equals KohaAdminEmailAddress'); |
1344 |
$sth->execute( $patron->borrowernumber ); |
1345 |
$to_address = $sth->fetchrow_array; |
1346 |
is( $to_address, 'root@localhost', 'OPAC_REG email queued to go to KohaAdminEmailAddress syspref when EmailPatronRegistration equals KohaAdminEmailAddress' ); |
1347 |
$dbh->do(q|DELETE FROM message_queue|); |
1348 |
|
1349 |
$schema->storage->txn_rollback; |
1350 |
}; |