Lines 611-618
subtest 'EmailPurchaseSuggestions' => sub {
Link Here
|
611 |
|
611 |
|
612 |
# EmailPurchaseSuggestions set to disabled |
612 |
# EmailPurchaseSuggestions set to disabled |
613 |
t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "0" ); |
613 |
t::lib::Mocks::mock_preference( "EmailPurchaseSuggestions", "0" ); |
|
|
614 |
$dbh->do(q|DELETE FROM message_queue|); |
614 |
Koha::Suggestion->new($my_suggestion)->store; |
615 |
Koha::Suggestion->new($my_suggestion)->store; |
615 |
my $newsuggestions_messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); |
616 |
my $newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
616 |
is( |
617 |
is( |
617 |
@$newsuggestions_messages, 0, |
618 |
@$newsuggestions_messages, 0, |
618 |
'New suggestion does not send an email when EmailPurchaseSuggestions disabled' |
619 |
'New suggestion does not send an email when EmailPurchaseSuggestions disabled' |
Lines 623-661
subtest 'EmailPurchaseSuggestions' => sub {
Link Here
|
623 |
t::lib::Mocks::mock_preference( "ReplytoDefault", "" ); |
624 |
t::lib::Mocks::mock_preference( "ReplytoDefault", "" ); |
624 |
t::lib::Mocks::mock_preference( "EmailAddressForSuggestions", "" ); |
625 |
t::lib::Mocks::mock_preference( "EmailAddressForSuggestions", "" ); |
625 |
Koha::Libraries->find('CPL')->update( { branchemail => '', branchreplyto => '' } ); |
626 |
Koha::Libraries->find('CPL')->update( { branchemail => '', branchreplyto => '' } ); |
|
|
627 |
$dbh->do(q|DELETE FROM message_queue|); |
626 |
Koha::Suggestion->new($my_suggestion)->store; |
628 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
629 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
630 |
my $message1 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
627 |
|
631 |
|
628 |
t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); |
632 |
t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); |
|
|
633 |
$dbh->do(q|DELETE FROM message_queue|); |
629 |
Koha::Suggestion->new($my_suggestion)->store; |
634 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
635 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
636 |
my $message2 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
630 |
|
637 |
|
631 |
Koha::Libraries->find('CPL')->update( { branchemail => 'branchemail@hosting.com' } ); |
638 |
Koha::Libraries->find('CPL')->update( { branchemail => 'branchemail@hosting.com' } ); |
|
|
639 |
$dbh->do(q|DELETE FROM message_queue|); |
632 |
Koha::Suggestion->new($my_suggestion)->store; |
640 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
641 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
642 |
my $message3 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
633 |
|
643 |
|
634 |
Koha::Libraries->find('CPL')->update( { branchreplyto => 'branchemail@b.c' } ); |
644 |
Koha::Libraries->find('CPL')->update( { branchreplyto => 'branchemail@b.c' } ); |
|
|
645 |
$dbh->do(q|DELETE FROM message_queue|); |
635 |
Koha::Suggestion->new($my_suggestion)->store; |
646 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
647 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
648 |
my $message4 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
636 |
|
649 |
|
637 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); |
|
|
638 |
isnt( @$newsuggestions_messages, 0, 'New suggestions sends an email wne EmailPurchaseSuggestions enabled' ); |
650 |
isnt( @$newsuggestions_messages, 0, 'New suggestions sends an email wne EmailPurchaseSuggestions enabled' ); |
639 |
my $message1 = |
|
|
640 |
C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
641 |
is( |
651 |
is( |
642 |
$message1->{to_address}, 'noreply@hosting.com', |
652 |
$message1->{to_address}, 'noreply@hosting.com', |
643 |
'BranchEmailAddress falls back to KohaAdminEmailAddress if branchreplyto, branchemail and ReplytoDefault are not set' |
653 |
'BranchEmailAddress falls back to KohaAdminEmailAddress if branchreplyto, branchemail and ReplytoDefault are not set' |
644 |
); |
654 |
); |
645 |
my $message2 = |
|
|
646 |
C4::Letters::GetMessage( $newsuggestions_messages->[1]->{message_id} ); |
647 |
is( |
655 |
is( |
648 |
$message2->{to_address}, 'library@b.c', |
656 |
$message2->{to_address}, 'library@b.c', |
649 |
'BranchEmailAddress falls back to ReplytoDefault if neither branchreplyto or branchemail are set' |
657 |
'BranchEmailAddress falls back to ReplytoDefault if neither branchreplyto or branchemail are set' |
650 |
); |
658 |
); |
651 |
my $message3 = |
|
|
652 |
C4::Letters::GetMessage( $newsuggestions_messages->[2]->{message_id} ); |
653 |
is( |
659 |
is( |
654 |
$message3->{to_address}, 'branchemail@hosting.com', |
660 |
$message3->{to_address}, 'branchemail@hosting.com', |
655 |
'BranchEmailAddress uses branchemail if branch_replto is not set' |
661 |
'BranchEmailAddress uses branchemail if branch_replto is not set' |
656 |
); |
662 |
); |
657 |
my $message4 = |
|
|
658 |
C4::Letters::GetMessage( $newsuggestions_messages->[3]->{message_id} ); |
659 |
is( |
663 |
is( |
660 |
$message4->{to_address}, 'branchemail@b.c', |
664 |
$message4->{to_address}, 'branchemail@b.c', |
661 |
'BranchEmailAddress uses branchreplyto in preference to branchemail when set' |
665 |
'BranchEmailAddress uses branchreplyto in preference to branchemail when set' |
Lines 668-687
subtest 'EmailPurchaseSuggestions' => sub {
Link Here
|
668 |
); |
672 |
); |
669 |
|
673 |
|
670 |
t::lib::Mocks::mock_preference( "ReplytoDefault", undef ); |
674 |
t::lib::Mocks::mock_preference( "ReplytoDefault", undef ); |
|
|
675 |
$dbh->do(q|DELETE FROM message_queue|); |
671 |
Koha::Suggestion->new($my_suggestion)->store; |
676 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
677 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
678 |
my $message5 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
672 |
|
679 |
|
673 |
t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); |
680 |
t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); |
|
|
681 |
$dbh->do(q|DELETE FROM message_queue|); |
674 |
Koha::Suggestion->new($my_suggestion)->store; |
682 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
683 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
684 |
my $message6 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
675 |
|
685 |
|
676 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); |
|
|
677 |
my $message5 = |
678 |
C4::Letters::GetMessage( $newsuggestions_messages->[4]->{message_id} ); |
679 |
is( |
686 |
is( |
680 |
$message5->{to_address}, |
687 |
$message5->{to_address}, |
681 |
'noreply@hosting.com', 'KohaAdminEmailAddress uses KohaAdminEmailAddress when ReplytoDefault is not set' |
688 |
'noreply@hosting.com', 'KohaAdminEmailAddress uses KohaAdminEmailAddress when ReplytoDefault is not set' |
682 |
); |
689 |
); |
683 |
my $message6 = |
|
|
684 |
C4::Letters::GetMessage( $newsuggestions_messages->[5]->{message_id} ); |
685 |
is( |
690 |
is( |
686 |
$message6->{to_address}, |
691 |
$message6->{to_address}, |
687 |
'library@b.c', 'KohaAdminEmailAddress uses ReplytoDefualt when ReplytoDefault is set' |
692 |
'library@b.c', 'KohaAdminEmailAddress uses ReplytoDefualt when ReplytoDefault is set' |
Lines 694-734
subtest 'EmailPurchaseSuggestions' => sub {
Link Here
|
694 |
); |
699 |
); |
695 |
|
700 |
|
696 |
t::lib::Mocks::mock_preference( "ReplytoDefault", undef ); |
701 |
t::lib::Mocks::mock_preference( "ReplytoDefault", undef ); |
|
|
702 |
$dbh->do(q|DELETE FROM message_queue|); |
697 |
Koha::Suggestion->new($my_suggestion)->store; |
703 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
704 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
705 |
my $message7 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
698 |
|
706 |
|
699 |
t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); |
707 |
t::lib::Mocks::mock_preference( "ReplytoDefault", 'library@b.c' ); |
|
|
708 |
$dbh->do(q|DELETE FROM message_queue|); |
700 |
Koha::Suggestion->new($my_suggestion)->store; |
709 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
710 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
711 |
my $message8 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
701 |
|
712 |
|
702 |
t::lib::Mocks::mock_preference( |
713 |
t::lib::Mocks::mock_preference( |
703 |
"EmailAddressForSuggestions", |
714 |
"EmailAddressForSuggestions", |
704 |
'suggestions@b.c' |
715 |
'suggestions@b.c' |
705 |
); |
716 |
); |
|
|
717 |
$dbh->do(q|DELETE FROM message_queue|); |
706 |
Koha::Suggestion->new($my_suggestion)->store; |
718 |
Koha::Suggestion->new($my_suggestion)->store; |
|
|
719 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages(); |
720 |
my $message9 = C4::Letters::GetMessage( $newsuggestions_messages->[0]->{message_id} ); |
707 |
|
721 |
|
708 |
$newsuggestions_messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); |
|
|
709 |
my $message7 = |
710 |
C4::Letters::GetMessage( $newsuggestions_messages->[6]->{message_id} ); |
711 |
is( |
722 |
is( |
712 |
$message7->{to_address}, |
723 |
$message7->{to_address}, |
713 |
'noreply@hosting.com', |
724 |
'noreply@hosting.com', |
714 |
'EmailAddressForSuggestions uses KohaAdminEmailAddress when neither EmailAddressForSuggestions or ReplytoDefault are set' |
725 |
'EmailAddressForSuggestions uses KohaAdminEmailAddress when neither EmailAddressForSuggestions or ReplytoDefault are set' |
715 |
); |
726 |
); |
716 |
|
727 |
|
717 |
my $message8 = |
|
|
718 |
C4::Letters::GetMessage( $newsuggestions_messages->[7]->{message_id} ); |
719 |
is( |
728 |
is( |
720 |
$message8->{to_address}, |
729 |
$message8->{to_address}, |
721 |
'library@b.c', 'EmailAddressForSuggestions uses ReplytoDefault when EmailAddressForSuggestions is not set' |
730 |
'library@b.c', 'EmailAddressForSuggestions uses ReplytoDefault when EmailAddressForSuggestions is not set' |
722 |
); |
731 |
); |
723 |
|
732 |
|
724 |
my $message9 = |
|
|
725 |
C4::Letters::GetMessage( $newsuggestions_messages->[8]->{message_id} ); |
726 |
is( |
733 |
is( |
727 |
$message9->{to_address}, |
734 |
$message9->{to_address}, |
728 |
'suggestions@b.c', 'EmailAddressForSuggestions uses EmailAddressForSuggestions when set' |
735 |
'suggestions@b.c', 'EmailAddressForSuggestions uses EmailAddressForSuggestions when set' |
729 |
); |
736 |
); |
730 |
}; |
737 |
}; |
731 |
|
|
|
732 |
subtest 'ModSuggestion should work on suggestions without a suggester' => sub { |
738 |
subtest 'ModSuggestion should work on suggestions without a suggester' => sub { |
733 |
plan tests => 2; |
739 |
plan tests => 2; |
734 |
|
740 |
|
735 |
- |
|
|