[otrs-cvs] otrs/scripts/test EmailParser.t,1.3,1.4

cvs-log at otrs.org cvs-log at otrs.org
Thu Apr 12 16:34:42 GMT 2007


Comments:
Update of /home/cvs/otrs/scripts/test
In directory lancelot:/tmp/cvs-serv2231/scripts/test

Modified Files:
	EmailParser.t 
Log Message:
Added more tests with umlaut and other stuff.

Author: martin

Index: EmailParser.t
===================================================================
RCS file: /home/cvs/otrs/scripts/test/EmailParser.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** EmailParser.t	26 Aug 2006 17:36:26 -0000	1.3
--- EmailParser.t	12 Apr 2007 16:34:37 -0000	1.4
***************
*** 1,5 ****
  # --
  # EmailParser.t - email parser tests
! # Copyright (C) 2001-2006 OTRS GmbH, http://otrs.org/
  # --
  # $Id$
--- 1,5 ----
  # --
  # EmailParser.t - email parser tests
! # Copyright (C) 2001-2007 OTRS GmbH, http://otrs.org/
  # --
  # $Id$
***************
*** 10,18 ****
  # --
  
  use Kernel::System::EmailParser;
  
  my $Home = $Self->{ConfigObject}->Get('Home');
  my @Array = ();
! open(IN, "< $Home/doc/test-email-3.box");
  while (<IN>) {
      push(@Array, $_);
--- 10,22 ----
  # --
  
+ use utf8;
+ use Digest::MD5 qw(md5_hex);
  use Kernel::System::EmailParser;
  
  my $Home = $Self->{ConfigObject}->Get('Home');
+ 
+ # test #1
  my @Array = ();
! open(IN, "< $Home/scripts/test/sample/PostMaster-Test1.box");
  while (<IN>) {
      push(@Array, $_);
***************
*** 25,34 ****
  );
  
- 
- 
  $Self->Is(
      $Self->{EmailParserObject}->GetParam(WHAT => 'To'),
      'darthvader at otrs.org',
!     "GetParam(WHAT => 'To')",
  );
  
--- 29,36 ----
  );
  
  $Self->Is(
      $Self->{EmailParserObject}->GetParam(WHAT => 'To'),
      'darthvader at otrs.org',
!     "#1 GetParam(WHAT => 'To')",
  );
  
***************
*** 36,46 ****
      $Self->{EmailParserObject}->GetParam(WHAT => 'From'),
      'Skywalker Attachment <skywalker at otrs.org>',
!     "GetParam(WHAT => 'From')",
  );
  
  $Self->Is(
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'Juergen Weber <juergen.qeber at air.com>'),
      'juergen.qeber at air.com',
!     "GetEmailAddress()",
  );
  
--- 38,70 ----
      $Self->{EmailParserObject}->GetParam(WHAT => 'From'),
      'Skywalker Attachment <skywalker at otrs.org>',
!     "#1 GetParam(WHAT => 'From')",
  );
  
  $Self->Is(
+     $Self->{EmailParserObject}->GetCharset(),
+     'us-ascii',
+     "#1 GetCharset()",
+ );
+ 
+ my @Attachments = $Self->{EmailParserObject}->GetAttachments();
+ $Self->False(
+     $Attachments[1]->{Filename} || '',
+     "#1 GetAttachments() - no attachments",
+ );
+ 
+ # test #2
+ my @Addresses = $Self->{EmailParserObject}->SplitAddressLine(
+     Line => 'Juergen Weber <juergen.qeber at air.com>, me at example.com, hans at example.com (Hans Huber)',
+ );
+ 
+ $Self->Is(
+     $Addresses[2],
+     'hans at example.com (Hans Huber)',
+     "#2 SplitAddressLine()",
+ );
+ $Self->Is(
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'Juergen Weber <juergen.qeber at air.com>'),
      'juergen.qeber at air.com',
!     "#1 GetEmailAddress()",
  );
  
***************
*** 48,52 ****
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'Juergen Weber <juergen+qeber at air.com>'),
      'juergen+qeber at air.com',
!     "GetEmailAddress()",
  );
  
--- 72,76 ----
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'Juergen Weber <juergen+qeber at air.com>'),
      'juergen+qeber at air.com',
!     "#1 GetEmailAddress()",
  );
  
***************
*** 54,58 ****
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'Juergen Weber <juergen+qeber at air.com> (Comment)'),
      'juergen+qeber at air.com',
!     "GetEmailAddress()",
  );
  
--- 78,82 ----
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'Juergen Weber <juergen+qeber at air.com> (Comment)'),
      'juergen+qeber at air.com',
!     "#1 GetEmailAddress()",
  );
  
***************
*** 60,88 ****
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'juergen+qeber at air.com (Comment)'),
      'juergen+qeber at air.com',
!     "GetEmailAddress()",
  );
  
  
! my @Addresses = $Self->{EmailParserObject}->SplitAddressLine(
!     Line => 'Juergen Weber <juergen.qeber at air.com>, me at example.com, hans at example.com (Hans Huber)',
  );
  
  $Self->Is(
!     $Addresses[2],
!     'hans at example.com (Hans Huber)',
!     "SplitAddressLine()",
  );
  
  $Self->Is(
      $Self->{EmailParserObject}->GetCharset(),
!     'us-ascii',
!     "GetCharset()",
  );
  
! my @Attachments = $Self->{EmailParserObject}->GetAttachments();
  $Self->Is(
      $Attachments[1]->{Filename},
!     'otrs.jpg',
!     "GetAttachments()",
  );
  
--- 84,311 ----
      $Self->{EmailParserObject}->GetEmailAddress(Email => 'juergen+qeber at air.com (Comment)'),
      'juergen+qeber at air.com',
!     "#1 GetEmailAddress()",
  );
  
+ # test #3
+ @Array = ();
+ open(IN, "< $Home/scripts/test/sample/PostMaster-Test3.box");
+ while (<IN>) {
+     push(@Array, $_);
+ }
+ close (IN);
  
! $Self->{EmailParserObject} = Kernel::System::EmailParser->new(
!     %{$Self},
!     Email => \@Array,
! );
! $Self->Is(
!     $Self->{EmailParserObject}->GetCharset(),
!     'UTF-8',
!     "#3 GetCharset()",
  );
+ @Attachments = $Self->{EmailParserObject}->GetAttachments();
+ if ($Self->{ConfigObject}->Get('DefaultCharset') =~ /utf/i) {
+     $Self->Is(
+         $Attachments[1]->{Filename},
+         'utf-8-file-äöüß-カスタマ.txt',
+         "#3 GetAttachments()",
+     );
+ }
  
+ # test #4
+ @Array = ();
+ open(IN, "< $Home/scripts/test/sample/PostMaster-Test4.box");
+ while (<IN>) {
+     push(@Array, $_);
+ }
+ close (IN);
+ 
+ $Self->{EmailParserObject} = Kernel::System::EmailParser->new(
+     %{$Self},
+     Email => \@Array,
+ );
  $Self->Is(
!     $Self->{EmailParserObject}->GetCharset(),
!     'iso-8859-15',
!     "#4 GetCharset()",
  );
+ if ($Self->{ConfigObject}->Get('DefaultCharset') =~ /utf/i) {
+     $Self->Is(
+         $Self->{EmailParserObject}->GetParam(WHAT => 'From'),
+         'Hans BÄKOSchönland <me at bogen.net>',
+         "#4 From()",
+     );
+     $Self->Is(
+         $Self->{EmailParserObject}->GetParam(WHAT => 'To'),
+         'Namedyński (hans at example.com)',
+         "#4 To()",
+     );
+     $Self->Is(
+         $Self->{EmailParserObject}->GetParam(WHAT => 'Subject'),
+         'utf8: 使って / ISO-8859-1:  Priorität"  / cp-1251: Сергей Углицких',
+         "#4 Subject()",
+     );
+ }
  
+ # test #5
+ @Array = ();
+ open(IN, "< $Home/scripts/test/sample/PostMaster-Test5.box");
+ while (<IN>) {
+     push(@Array, $_);
+ }
+ close (IN);
+ 
+ $Self->{EmailParserObject} = Kernel::System::EmailParser->new(
+     %{$Self},
+     Email => \@Array,
+ );
  $Self->Is(
      $Self->{EmailParserObject}->GetCharset(),
!     'iso-8859-1',
!     "#5 GetCharset()",
! );
! @Attachments = $Self->{EmailParserObject}->GetAttachments();
! my $MD5 = md5_hex($Attachments[1]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     '0596f2939525c6bd50fc2b649e40fbb6',
!     "#5 md5 check",
! );
! $Self->Is(
!     $Attachments[1]->{Filename},
!     'test-attachment-äöüß-iso-8859-1.txt',
!     "#5 GetAttachments()",
! );
! $MD5 = md5_hex($Attachments[2]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     'bb29962e132ba159539f1e88b41663b1',
!     "#5 md5 check",
! );
! $Self->Is(
!     $Attachments[2]->{Filename},
!     'test-attachment-äöüß-utf-8.txt',
!     "#5 GetAttachments()",
! );
! $MD5 = md5_hex($Attachments[3]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     '5ee767f3b68f24a9213e0bef82dc53e5',
!     "#5 md5 check",
! );
! $Self->Is(
!     $Attachments[3]->{Filename},
!     'test-attachment-äöüß.pdf',
!     "#5 GetAttachments()",
  );
  
! # test #6
! @Array = ();
! open(IN, "< $Home/scripts/test/sample/PostMaster-Test6.box");
! while (<IN>) {
!     push(@Array, $_);
! }
! close (IN);
! 
! $Self->{EmailParserObject} = Kernel::System::EmailParser->new(
!     %{$Self},
!     Email => \@Array,
! );
! $Self->Is(
!     $Self->{EmailParserObject}->GetCharset(),
!     'utf-8',
!     "#6 GetCharset()",
! );
! @Attachments = $Self->{EmailParserObject}->GetAttachments();
! $MD5 = md5_hex($Attachments[1]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     '5ee767f3b68f24a9213e0bef82dc53e5',
!     "#6 md5 check",
! );
! if ($Self->{ConfigObject}->Get('DefaultCharset') =~ /utf/i) {
!     $Self->Is(
!         $Attachments[1]->{Filename},
!         'test-attachment-äöüß.pdf',
!         "#6 GetAttachments()",
!     );
! }
! $MD5 = md5_hex($Attachments[2]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     'bb29962e132ba159539f1e88b41663b1',
!     "#6 md5 check",
! );
! if ($Self->{ConfigObject}->Get('DefaultCharset') =~ /utf/i) {
!     $Self->Is(
!         $Attachments[2]->{Filename},
!         'test-attachment-äöüß-utf-8.txt',
!         "#6 GetAttachments()",
!     );
! }
! $MD5 = md5_hex($Attachments[3]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     '0596f2939525c6bd50fc2b649e40fbb6',
!     "#6 md5 check",
! );
! if ($Self->{ConfigObject}->Get('DefaultCharset') =~ /utf/i) {
!     $Self->Is(
!         $Attachments[3]->{Filename},
!         'test-attachment-äöüß-iso-8859-1.txt',
!         "#6 GetAttachments()",
!     );
! }
! 
! # test #7
! @Array = ();
! open(IN, "< $Home/scripts/test/sample/PostMaster-Test7.box");
! while (<IN>) {
!     push(@Array, $_);
! }
! close (IN);
! 
! $Self->{EmailParserObject} = Kernel::System::EmailParser->new(
!     %{$Self},
!     Email => \@Array,
! );
! $Self->Is(
!     $Self->{EmailParserObject}->GetCharset(),
!     'iso-8859-1',
!     "#7 GetCharset()",
! );
! @Attachments = $Self->{EmailParserObject}->GetAttachments();
! $MD5 = md5_hex($Attachments[1]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     '5ee767f3b68f24a9213e0bef82dc53e5',
!     "#7 md5 check",
! );
  $Self->Is(
      $Attachments[1]->{Filename},
!     'test-attachment-äöüß.pdf',
!     "#7 GetAttachments()",
! );
! $MD5 = md5_hex($Attachments[2]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     'bb29962e132ba159539f1e88b41663b1',
!     "#7 md5 check",
! );
! $Self->Is(
!     $Attachments[2]->{Filename},
!     'test-attachment-äöüß-utf-8.txt',
!     "#7 GetAttachments()",
! );
! $MD5 = md5_hex($Attachments[3]->{Content}) || '';
! $Self->Is(
!     $MD5,
!     '0596f2939525c6bd50fc2b649e40fbb6',
!     "#7 md5 check",
! );
! $Self->Is(
!     $Attachments[3]->{Filename},
!     'test-attachment-äöüß-iso-8859-1.txt',
!     "#7 GetAttachments()",
  );
  


More information about the cvs-log mailing list