|
Lines 18-24
Link Here
|
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
use Test::More tests => 64; |
21 |
use Test::More tests => 65; |
| 22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
|
Lines 490-495
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notificatio
Link Here
|
| 490 |
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully'); |
490 |
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully'); |
| 491 |
} |
491 |
} |
| 492 |
|
492 |
|
|
|
493 |
subtest 'SendAlerts - claimissue' => sub { |
| 494 |
plan tests => 8; |
| 495 |
|
| 496 |
use C4::Serials; |
| 497 |
|
| 498 |
$dbh->do(q{INSERT INTO letter (module, code, name, title, content) VALUES ('claimissues','TESTSERIALCLAIM','Serial claim test','Serial claim test','<<serial.serialid>>|<<subscription.startdate>>|<<biblio.title>>|<<biblioitems.issn>>');}); |
| 499 |
|
| 500 |
my $bookseller = Koha::Acquisition::Bookseller->new( |
| 501 |
{ |
| 502 |
name => "my vendor", |
| 503 |
address1 => "bookseller's address", |
| 504 |
phone => "0123456", |
| 505 |
active => 1, |
| 506 |
deliverytime => 5, |
| 507 |
} |
| 508 |
)->store; |
| 509 |
my $booksellerid = $bookseller->id; |
| 510 |
|
| 511 |
Koha::Acquisition::Bookseller::Contact->new( { name => 'Leo Tolstoy', phone => '0123456x2', claimissues => 1, booksellerid => $booksellerid } )->store; |
| 512 |
|
| 513 |
my $bib = MARC::Record->new(); |
| 514 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
| 515 |
$bib->append_fields( |
| 516 |
MARC::Field->new('011', ' ', ' ', a => 'xxxx-yyyy'), |
| 517 |
MARC::Field->new('200', ' ', ' ', a => 'Silence in the library'), |
| 518 |
); |
| 519 |
} else { |
| 520 |
$bib->append_fields( |
| 521 |
MARC::Field->new('022', ' ', ' ', a => 'xxxx-yyyy'), |
| 522 |
MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'), |
| 523 |
); |
| 524 |
} |
| 525 |
my ($biblionumber) = AddBiblio($bib, ''); |
| 526 |
|
| 527 |
$dbh->do(q|UPDATE subscription_numberpatterns SET numberingmethod='No. {X}' WHERE id=1|); |
| 528 |
my $subscriptionid = NewSubscription( |
| 529 |
undef, "", $booksellerid, undef, undef, $biblionumber, |
| 530 |
'2013-01-01', 1, undef, undef, undef, |
| 531 |
undef, undef, undef, undef, undef, undef, |
| 532 |
1, 'public',undef, '2013-01-01', undef, 1, |
| 533 |
undef, undef, 0, 'internal', 0, |
| 534 |
undef, undef, 0, undef, '2013-12-31', 0 |
| 535 |
); |
| 536 |
|
| 537 |
my ($serials_count, @serials) = GetSerials($subscriptionid); |
| 538 |
my @serialids = ($serials[0]->{serialid}); |
| 539 |
|
| 540 |
my $err; |
| 541 |
warning_like { |
| 542 |
$err = SendAlerts( 'claimissues', \@serialids, 'TESTSERIALCLAIM' ) } |
| 543 |
qr/^Bookseller .* without emails at/, |
| 544 |
"Warn on vendor without email address"; |
| 545 |
|
| 546 |
$bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); |
| 547 |
$bookseller->contacts->next->email('testemail@mydomain.com')->store; |
| 548 |
|
| 549 |
# Ensure that the preference 'LetterLog' is set to logging |
| 550 |
t::lib::Mocks::mock_preference( 'LetterLog', 'on' ); |
| 551 |
|
| 552 |
# SendAlerts needs branchemail or KohaAdminEmailAddress as sender |
| 553 |
C4::Context->_new_userenv('DUMMY'); |
| 554 |
C4::Context->set_userenv( 0, 0, 0, 'firstname', 'surname', $library->{branchcode}, 'My Library', 0, '', ''); |
| 555 |
t::lib::Mocks::mock_preference( 'KohaAdminEmailAddress', 'library@domain.com' ); |
| 556 |
|
| 557 |
{ |
| 558 |
warning_is { |
| 559 |
$err = SendAlerts( 'claimissues', \@serialids , 'TESTSERIALCLAIM' ) } |
| 560 |
"Fake sendmail", |
| 561 |
"SendAlerts is using the mocked sendmail routine (claimissues)"; |
| 562 |
is($err, 1, "Successfully sent claim"); |
| 563 |
is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent claim"); |
| 564 |
is($mail{'Message'}, "$serialids[0]|2013-01-01|Silence in the library|xxxx-yyyy", 'Serial claim letter for 1 issue constructed successfully'); |
| 565 |
} |
| 566 |
|
| 567 |
{ |
| 568 |
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); |
| 569 |
my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0]; |
| 570 |
ModSerialStatus( $serials[0]->{serialid}, "No. 1", $publisheddate, $publisheddate, $publisheddate, '3', 'a note' ); |
| 571 |
($serials_count, @serials) = GetSerials($subscriptionid); |
| 572 |
push @serialids, ($serials[1]->{serialid}); |
| 573 |
|
| 574 |
$err = SendAlerts( 'claimissues', \@serialids , 'TESTSERIALCLAIM' ); |
| 575 |
is($mail{'Message'}, "$serialids[0]|2013-01-01|Silence in the library|xxxx-yyyy\n$serialids[1]|2013-01-01|Silence in the library|xxxx-yyyy", "Serial claim letter for 2 issues constructed successfully"); |
| 576 |
|
| 577 |
$dbh->do(q{DELETE FROM letter WHERE code = 'TESTSERIALCLAIM';}); |
| 578 |
warning_like { |
| 579 |
$err = SendAlerts( 'orderacquisition', $basketno , 'TESTSERIALCLAIM' ) } |
| 580 |
qr/No orderacquisition TESTSERIALCLAIM letter transported by email/, |
| 581 |
"GetPreparedLetter warns about missing notice template"; |
| 582 |
is($err->{'error'}, 'no_letter', "No TESTSERIALCLAIM letter was defined"); |
| 583 |
} |
| 584 |
|
| 585 |
}; |
| 586 |
|
| 493 |
subtest 'GetPreparedLetter' => sub { |
587 |
subtest 'GetPreparedLetter' => sub { |
| 494 |
plan tests => 4; |
588 |
plan tests => 4; |
| 495 |
|
589 |
|