From dbaef9ecee4cbc423d909e50dd240ea9319d9c47 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Fri, 2 Dec 2016 16:16:30 +0000
Subject: [PATCH] Bug 15969 - Unit test use of __MESSAGE_ID__

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 t/db_dependent/Letters.t | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t
index e20cefb..c22a39f 100644
--- a/t/db_dependent/Letters.t
+++ b/t/db_dependent/Letters.t
@@ -18,7 +18,7 @@
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
-use Test::More tests => 77;
+use Test::More tests => 78;
 use Test::MockModule;
 use Test::Warn;
 
@@ -103,7 +103,7 @@ is( $message_id, undef, 'EnqueueLetter without the letter argument returns undef
 
 delete $my_message->{message_transport_type};
 $my_message->{letter} = {
-    content      => 'a message',
+    content      => 'a message:__MESSAGE_ID__',
     title        => 'message title',
     metadata     => 'metadata',
     code         => 'TEST_MESSAGE',
@@ -127,7 +127,8 @@ is( @$messages, 1, 'one message stored for the borrower' );
 is( $messages->[0]->{message_id}, $message_id, 'EnqueueLetter returns the message id correctly' );
 is( $messages->[0]->{borrowernumber}, $borrowernumber, 'EnqueueLetter stores the borrower number correctly' );
 is( $messages->[0]->{subject}, $my_message->{letter}->{title}, 'EnqueueLetter stores the subject correctly' );
-is( $messages->[0]->{content}, $my_message->{letter}->{content}, 'EnqueueLetter stores the content correctly' );
+is( @{[ split( /:/, $messages->[0]->{content} ) ]}[0], @{[ split( /:/, $my_message->{letter}->{content} ) ]}[0], 'EnqueueLetter stores the content correctly' );
+ok( @{[ split( /:/, $messages->[0]->{content} ) ]}[1] =~ /^\d+$/, 'Content __MESSAGE_ID__ is replaced with an actual integer id' );
 is( $messages->[0]->{message_transport_type}, $my_message->{message_transport_type}, 'EnqueueLetter stores the message type correctly' );
 is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pending correctly' );
 
-- 
2.10.2