File: header-prepend.t

package info (click to toggle)
libemail-simple-perl 2.218-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: perl: 462; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,288 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use v5.12.0;
use warnings;

use Test::More;

# This test is not here to encourage you to muck about in the object guts, but
# to provide a test for when Email::Simple has a way to provide optional
# extended header munging.

use_ok('Email::Simple');

my $email_text = <<END_MESSAGE;
Alpha: this header comes first
Bravo: this header comes second
Alpha: this header comes third

The body is irrelevant.
END_MESSAGE

my $email = Email::Simple->new($email_text);
isa_ok($email, "Email::Simple");

$email->header_raw_prepend(Alpha => 'this header comes firstest');

is_deeply(
  [ $email->header_pairs ],
  [
    Alpha => 'this header comes firstest',
    Alpha => 'this header comes first',
    Bravo => 'this header comes second',
    Alpha => 'this header comes third',
  ],
  "we can prepend an existing header",
);

$email->header_raw_prepend('Zero' => 'and 0+1th');
$email->header_raw_prepend('Zero' => 'this header comes zeroeth');

is_deeply(
  [ $email->header_pairs ],
  [
    Zero  => 'this header comes zeroeth',
    Zero  => 'and 0+1th',
    Alpha => 'this header comes firstest',
    Alpha => 'this header comes first',
    Bravo => 'this header comes second',
    Alpha => 'this header comes third',
  ],
  "we can prepend mutiply, too, and to a new header",
);

done_testing;