]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/t/25-lp1955079-opac-mime-email.t
LP#1955079: Use Email::MIME for emailing records in the OPAC
[working/Evergreen.git] / Open-ILS / src / perlmods / t / 25-lp1955079-opac-mime-email.t
1 #!perl -T
2
3 use strict; use warnings;
4 use Test::More tests => 4;
5
6 BEGIN {
7   use_ok( 'OpenILS::Application::Search' );
8 }
9
10 use_ok( 'OpenILS::Application::Search::Biblio' );
11 can_ok( 'OpenILS::Application::Search::Biblio', '_create_mime_email' );
12
13 my $raw_email = <<'END_EMAIL';
14 To: test@example.com
15 From: no-reply@localhost.com
16 Date: Thu, 05 May 2022 18:21:48 -0000
17 Subject: Bibliographic Records
18 Auto-Submitted: auto-generated
19 END_EMAIL
20
21 my @expected_headers = [
22   'To' => 'test@example.com',
23   'From' => 'no-reply@localhost.com',
24   'Date' => 'Thu, 05 May 2022 18:21:48 -0000',
25   'Subject' => 'Bibliographic Records',
26   'Auto-Submitted' => 'auto-generated',
27   'MIME-Version' => '1.0',
28   'Content-Type' => 'text/plain; charset=UTF-8',
29   'Content-Transfer-Encoding' => '8bit'
30 ];
31
32 my $mime_email = OpenILS::Application::Search::Biblio::_create_mime_email($raw_email);
33 my @actual_headers = $mime_email->header_str_pairs;
34
35 is_deeply(\@actual_headers, @expected_headers, 'Headers do not get mangled in the process');
36
37 1;
38