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 => 77; |
21 |
use Test::More tests => 78; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
Lines 48-53
use Koha::Acquisition::Bookseller::Contacts;
Link Here
|
48 |
use Koha::Acquisition::Orders; |
48 |
use Koha::Acquisition::Orders; |
49 |
use Koha::Libraries; |
49 |
use Koha::Libraries; |
50 |
use Koha::Notice::Templates; |
50 |
use Koha::Notice::Templates; |
|
|
51 |
use Koha::Notice::Messages; |
52 |
|
51 |
my $schema = Koha::Database->schema; |
53 |
my $schema = Koha::Database->schema; |
52 |
$schema->storage->txn_begin(); |
54 |
$schema->storage->txn_begin(); |
53 |
|
55 |
|
Lines 753-759
subtest 'Test limit parameter for SendQueuedMessages' => sub {
Link Here
|
753 |
}; |
755 |
}; |
754 |
|
756 |
|
755 |
subtest 'Test canary call for SendQueuedMessages' => sub { |
757 |
subtest 'Test canary call for SendQueuedMessages' => sub { |
756 |
plan tests => 2; |
758 |
plan tests => 4; |
757 |
|
759 |
|
758 |
my $letter = { |
760 |
my $letter = { |
759 |
'letter' => { |
761 |
'letter' => { |
Lines 768-781
subtest 'Test canary call for SendQueuedMessages' => sub {
Link Here
|
768 |
'message_transport_type' => 'email', |
770 |
'message_transport_type' => 'email', |
769 |
'from_address' => 'from@example.com' |
771 |
'from_address' => 'from@example.com' |
770 |
}; |
772 |
}; |
771 |
C4::Letters::EnqueueLetter($letter); |
773 |
my $queued_msg = Koha::Notice::Messages->find( |
|
|
774 |
C4::Letters::EnqueueLetter($letter), |
775 |
); |
776 |
is( $queued_msg->status, 'pending', 'Status should be pending now' ); |
772 |
|
777 |
|
773 |
my $mocked_storing = Test::MockModule->new('Koha::Object'); |
778 |
my $mocked_storing = Test::MockModule->new('Koha::Object'); |
774 |
$mocked_storing->mock('store' => sub { return; }); |
779 |
$mocked_storing->mock('store' => sub { return; }); |
775 |
$messages_processed = C4::Letters::SendQueuedMessages(); |
780 |
is( C4::Letters::SendQueuedMessages(), undef, 'Bad store should prevent handling any messages.' ); |
776 |
is( $messages_processed, undef, 'Bad store should prevent sending any.'); |
781 |
$queued_msg->discard_changes; # refresh |
|
|
782 |
is( $queued_msg->status, 'pending', 'Status still pending' ); |
783 |
|
777 |
$mocked_storing->unmock('store'); |
784 |
$mocked_storing->unmock('store'); |
778 |
$messages_processed = C4::Letters::SendQueuedMessages(); |
785 |
C4::Letters::SendQueuedMessages(); |
779 |
is( $messages_processed, 1, 'Good store should send.'); |
786 |
$queued_msg->discard_changes; # refresh again |
|
|
787 |
is( $queued_msg->status, 'failed', 'Good store and mocked sendmail should trigger status change.' ); |
788 |
}; |
780 |
|
789 |
|
781 |
} |
790 |
$schema->storage->txn_rollback; |
782 |
- |
|
|