File: emailparser.t

package info (click to toggle)
request-tracker4 4.4.7%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 62,888 kB
  • sloc: javascript: 130,444; perl: 65,442; sh: 1,350; makefile: 480; python: 37; php: 30
file content (38 lines) | stat: -rw-r--r-- 1,460 bytes parent folder | download | duplicates (8)
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

use strict;
use warnings;

use RT::Test nodb => 1, tests => undef;

ok(require RT::EmailParser);

RT->Config->Set( RTAddressRegexp => undef );
is(RT::EmailParser::IsRTAddress("",""),undef, "Empty emails from users don't match queues without email addresses" );

RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );

is(RT::EmailParser::IsRTAddress("","rt\@example.com"),1, "Regexp matched rt address" );
is(RT::EmailParser::IsRTAddress("","frt\@example.com"),undef, "Regexp didn't match non-rt address" );

my @before = ("rt\@example.com", "frt\@example.com");
my @after = ("frt\@example.com");
ok(eq_array(RT::EmailParser->CullRTAddresses(@before),@after), "CullRTAddresses only culls RT addresses");

{
    my ( $addr ) =
      RT::EmailParser->ParseEmailAddress('foo@example.com');
    is( $addr->address, 'foo@example.com', 'addr for foo@example.com' );
    is( $addr->phrase,  undef,             'no name for foo@example.com' );

    ( $addr ) =
      RT::EmailParser->ParseEmailAddress('Foo <foo@example.com>');
    is( $addr->address, 'foo@example.com', 'addr for Foo <foo@example.com>' );
    is( $addr->phrase,  'Foo',             'name for Foo <foo@example.com>' );

    ( $addr ) =
      RT::EmailParser->ParseEmailAddress('foo@example.com (Comment)');
    is( $addr->address, 'foo@example.com', 'addr for foo@example.com (Comment)' );
    is( $addr->phrase,  undef,             'no name for foo@example.com (Comment)' );
}

done_testing;