5 use RT::Test tests => 11;
7 ok(require RT::EmailParser);
9 RT->Config->Set( RTAddressRegexp => undef );
10 is(RT::EmailParser::IsRTAddress("",""),undef, "Empty emails from users don't match queues without email addresses" );
12 RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );
14 is(RT::EmailParser::IsRTAddress("","rt\@example.com"),1, "Regexp matched rt address" );
15 is(RT::EmailParser::IsRTAddress("","frt\@example.com"),undef, "Regexp didn't match non-rt address" );
17 my @before = ("rt\@example.com", "frt\@example.com");
18 my @after = ("frt\@example.com");
19 ok(eq_array(RT::EmailParser->CullRTAddresses(@before),@after), "CullRTAddresses only culls RT addresses");
22 require RT::Interface::Email;
24 RT::Interface::Email::ParseAddressFromHeader('foo@example.com');
25 is( $addr, 'foo@example.com', 'addr for foo@example.com' );
26 is( $name, undef, 'no name for foo@example.com' );
29 RT::Interface::Email::ParseAddressFromHeader('Foo <foo@example.com>');
30 is( $addr, 'foo@example.com', 'addr for Foo <foo@example.com>' );
31 is( $name, 'Foo', 'name for Foo <foo@example.com>' );
34 RT::Interface::Email::ParseAddressFromHeader('foo@example.com (Comment)');
35 is( $addr, 'foo@example.com', 'addr for foo@example.com (Comment)' );
36 is( $name, undef, 'no name for foo@example.com (Comment)' );