[otrs-cvs] ImportExport/scripts/test ImportExport.t,1.11,1.12

cvs-log at otrs.org cvs-log at otrs.org
Wed Mar 26 17:35:19 GMT 2008


Comments:
Update of /home/cvs/ImportExport/scripts/test
In directory lancelot:/tmp/cvs-serv8687/scripts/test

Modified Files:
	ImportExport.t 
Log Message:
Improved unittests.

Author: mh

Index: ImportExport.t
===================================================================
RCS file: /home/cvs/ImportExport/scripts/test/ImportExport.t,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** ImportExport.t	26 Mar 2008 12:26:33 -0000	1.11
--- ImportExport.t	26 Mar 2008 17:35:14 -0000	1.12
***************
*** 1,4 ****
  # --
! # ImportExport.t - import export tests
  # Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
  # --
--- 1,4 ----
  # --
! # ImportExport.t - all general import export tests
  # Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
  # --
***************
*** 62,66 ****
  my @TemplateName;
  
! for my $Counter ( 1 .. 3 ) {
  
      push @TemplateName, 'UnitTest' . int rand 1_000_000;
--- 62,66 ----
  my @TemplateName;
  
! for my $Counter ( 1 .. 5 ) {
  
      push @TemplateName, 'UnitTest' . int rand 1_000_000;
***************
*** 69,129 ****
  # create needed random object names
  my @ObjectName;
  
! for my $Counter ( 1 .. 1 ) {
! 
!     push @ObjectName, 'UnitTest' . int rand 1_000_000;
! }
! 
! # ------------------------------------------------------------ #
! # ObjectList() test
! # ------------------------------------------------------------ #
! 
! # get object list
! my $ObjectList1 = $Self->{ImportExportObject}->ObjectList();
  
! # list must be a hash reference
! $Self->True(
!     ref $ObjectList1 eq 'HASH',
!     '#1 ObjectList() - hash reference',
  );
  
! # list must have valid content
! if ( ref $ObjectList1 eq 'HASH' ) {
! 
!     my $Counter1 = 1;
!     for my $Key ( keys %{$ObjectList1} ) {
!         $Self->True(
!             $Key && $ObjectList1->{$Key} && !ref $ObjectList1->{$Key},
!             "#$Counter1 ObjectList() - valid content",
!         );
!         $Counter1++;
!     }
! }
! 
! # ------------------------------------------------------------ #
! # TemplateList() test #1
! # ------------------------------------------------------------ #
! 
! # get template list
! my $TemplateList1 = $Self->{ImportExportObject}->TemplateList(
      Object => $ObjectName[0],
      UserID => 1,
  );
  
- # list must be an empty array reference
- $Self->True(
-     ref $TemplateList1 eq 'ARRAY' && scalar @{$TemplateList1} eq 0,
-     "#1 TemplateList() - empty array reference",
- );
- 
  # ------------------------------------------------------------ #
! # TemplateAdd() tests
  # ------------------------------------------------------------ #
  
! my $TemplateChecks = [
  
      # this template is NOT complete and must not be added
      {
          Add => {
              Name    => $TemplateName[0],
              ValidID => 1,
--- 69,98 ----
  # create needed random object names
  my @ObjectName;
+ push @ObjectName, 'UnitTest' . int rand 1_000_000;
  
! # create needed format names
! my @FormatName = ('CSV');
  
! # get original template list for later checks (all elements)
! my $TemplateList1All = $Self->{ImportExportObject}->TemplateList(
!     UserID => 1,
  );
  
! # get original template list for later checks (all elements)
! my $TemplateList1Object = $Self->{ImportExportObject}->TemplateList(
      Object => $ObjectName[0],
      UserID => 1,
  );
  
  # ------------------------------------------------------------ #
! # define general tests
  # ------------------------------------------------------------ #
  
! my $ItemData = [
  
      # this template is NOT complete and must not be added
      {
          Add => {
+             Format  => $FormatName[0],
              Name    => $TemplateName[0],
              ValidID => 1,
***************
*** 136,139 ****
--- 105,109 ----
          Add => {
              Object  => $ObjectName[0],
+             Name    => $TemplateName[0],
              ValidID => 1,
              UserID  => 1,
***************
*** 144,150 ****
      {
          Add => {
!             Object => $ObjectName[0],
!             Name   => $TemplateName[0],
!             UserID => 1,
          },
      },
--- 114,121 ----
      {
          Add => {
!             Object  => $ObjectName[0],
!             Format  => $FormatName[0],
!             ValidID => 1,
!             UserID  => 1,
          },
      },
***************
*** 153,159 ****
      {
          Add => {
!             Object  => $ObjectName[0],
!             Name    => $TemplateName[0],
!             ValidID => 1,
          },
      },
--- 124,131 ----
      {
          Add => {
!             Object => $ObjectName[0],
!             Format => $FormatName[0],
!             Name   => $TemplateName[0],
!             UserID => 1,
          },
      },
***************
*** 163,167 ****
          Add => {
              Object  => $ObjectName[0],
!             Format  => 'CSV',
              ValidID => 1,
          },
--- 135,140 ----
          Add => {
              Object  => $ObjectName[0],
!             Format  => $FormatName[0],
!             Name    => $TemplateName[0],
              ValidID => 1,
          },
***************
*** 172,176 ****
          Add => {
              Object  => $ObjectName[0],
!             Format  => 'CSV',
              Name    => $TemplateName[0],
              ValidID => 1,
--- 145,149 ----
          Add => {
              Object  => $ObjectName[0],
!             Format  => $FormatName[0],
              Name    => $TemplateName[0],
              ValidID => 1,
***************
*** 179,183 ****
          AddGet => {
              Object   => $ObjectName[0],
!             Format   => 'CSV',
              Name     => $TemplateName[0],
              ValidID  => 1,
--- 152,156 ----
          AddGet => {
              Object   => $ObjectName[0],
!             Format   => $FormatName[0],
              Name     => $TemplateName[0],
              ValidID  => 1,
***************
*** 192,196 ****
          Add => {
              Object  => $ObjectName[0],
!             Format  => 'CSV',
              Name    => $TemplateName[0],
              ValidID => 1,
--- 165,169 ----
          Add => {
              Object  => $ObjectName[0],
!             Format  => $FormatName[0],
              Name    => $TemplateName[0],
              ValidID => 1,
***************
*** 203,218 ****
          Add => {
              Object  => $ObjectName[0],
!             Format  => 'CSV',
              Name    => $TemplateName[1],
              ValidID => 1,
!             Comment => 'This is a test!',
              UserID  => 1,
          },
          AddGet => {
              Object   => $ObjectName[0],
!             Format   => 'CSV',
              Name     => $TemplateName[1],
              ValidID  => 1,
!             Comment  => 'This is a test!',
              CreateBy => 1,
              ChangeBy => 1,
--- 176,191 ----
          Add => {
              Object  => $ObjectName[0],
!             Format  => $FormatName[0],
              Name    => $TemplateName[1],
              ValidID => 1,
!             Comment => 'TestComment',
              UserID  => 1,
          },
          AddGet => {
              Object   => $ObjectName[0],
!             Format   => $FormatName[0],
              Name     => $TemplateName[1],
              ValidID  => 1,
!             Comment  => 'TestComment',
              CreateBy => 1,
              ChangeBy => 1,
***************
*** 248,252 ****
          Update => {
              Name    => $TemplateName[1] . 'UPDATE3',
!             Comment => 'This is a second test!',
              ValidID => 2,
              UserID  => $UserIDs[0],
--- 221,225 ----
          Update => {
              Name    => $TemplateName[1] . 'UPDATE3',
!             Comment => 'TestComment UPDATE3',
              ValidID => 2,
              UserID  => $UserIDs[0],
***************
*** 255,259 ****
              Name     => $TemplateName[1] . 'UPDATE3',
              ValidID  => 2,
!             Comment  => 'This is a second test!',
              CreateBy => 1,
              ChangeBy => $UserIDs[0],
--- 228,232 ----
              Name     => $TemplateName[1] . 'UPDATE3',
              ValidID  => 2,
!             Comment  => 'TestComment UPDATE3',
              CreateBy => 1,
              ChangeBy => $UserIDs[0],
***************
*** 278,313 ****
      },
  
-     # the template one add-test before must be updated (template update arguments are complete)
-     {
-         Update => {
-             Name    => $TemplateName[1] . 'Update5',
-             ValidID => 1,
-             Comment => 'This is a comment.',
-             UserID  => 1,
-         },
-         UpdateGet => {
-             Name     => $TemplateName[1] . 'Update5',
-             ValidID  => 1,
-             Comment  => 'This is a comment.',
-             CreateBy => 1,
-             ChangeBy => 1,
-         },
-     },
- 
      # this template must be inserted sucessfully (check string cleaner function)
      {
          Add => {
              Object  => " \t \n \r " . $ObjectName[0] . " \t \n \r ",
!             Format  => " \t \n \r CSV \t \n \r ",
              Name    => " \t \n \r " . $TemplateName[2] . " \t \n \r ",
              ValidID => 1,
              UserID  => 1,
          },
          AddGet => {
              Object   => $ObjectName[0],
!             Format   => 'CSV',
              Name     => $TemplateName[2],
              ValidID  => 1,
!             Comment  => '',
              CreateBy => 1,
              ChangeBy => 1,
--- 251,270 ----
      },
  
      # this template must be inserted sucessfully (check string cleaner function)
      {
          Add => {
              Object  => " \t \n \r " . $ObjectName[0] . " \t \n \r ",
!             Format  => " \t \n \r " . $FormatName[0] . " \t \n \r ",
              Name    => " \t \n \r " . $TemplateName[2] . " \t \n \r ",
              ValidID => 1,
+             Comment => " \t \n \r Test Comment \t \n \r ",
              UserID  => 1,
          },
          AddGet => {
              Object   => $ObjectName[0],
!             Format   => $FormatName[0],
              Name     => $TemplateName[2],
              ValidID  => 1,
!             Comment  => 'Test Comment',
              CreateBy => 1,
              ChangeBy => 1,
***************
*** 320,323 ****
--- 277,281 ----
              Name    => " \t \n \r " . $TemplateName[2] . "UPDATE1 \t \n \r ",
              ValidID => 1,
+             Comment => " \t \n \r Test Comment UPDATE1 \t \n \r ",
              UserID  => 1,
          },
***************
*** 325,328 ****
--- 283,308 ----
              Name     => $TemplateName[2] . 'UPDATE1',
              ValidID  => 1,
+             Comment  => 'Test Comment UPDATE1',
+             CreateBy => 1,
+             ChangeBy => 1,
+         },
+     },
+ 
+     # this template must be inserted sucessfully (unicode checks)
+     {
+         Add => {
+             Object  => ' ƕ Ƙ ' . $ObjectName[0] . ' Ƶ ƻ ',
+             Format  => ' Ǔ ǣ ' . $FormatName[0] . ' ǥ Ǯ ',
+             Name    => ' Ƿ Ȝ ' . $TemplateName[3] . ' Ȟ Ƞ ',
+             ValidID => 2,
+             Comment => ' Ѡ Ѥ TestComment5 Ϡ Ω ',
+             UserID  => 1,
+         },
+         AddGet => {
+             Object   => 'ƕƘ' . $ObjectName[0] . 'Ƶƻ',
+             Format   => 'Ǔǣ' . $FormatName[0] . 'ǥǮ',
+             Name     => 'Ƿ Ȝ ' . $TemplateName[3] . ' Ȟ Ƞ',
+             ValidID  => 2,
+             Comment  => 'Ѡ Ѥ TestComment5 Ϡ Ω',
              CreateBy => 1,
              ChangeBy => 1,
***************
*** 331,344 ****
  ];
  
! my $IteratorCounter = 1;
! my $AddCounter      = 0;
  my $LastAddedTemplateID;
  TEMPLATE:
! for my $Template ( @{$TemplateChecks} ) {
  
!     if ( $Template->{Add} ) {
  
          # add new template
!         my $TemplateID = $Self->{ImportExportObject}->TemplateAdd( %{ $Template->{Add} } );
  
          if ($TemplateID) {
--- 311,329 ----
  ];
  
! # ------------------------------------------------------------ #
! # run general tests
! # ------------------------------------------------------------ #
! 
! my $TestCount  = 1;
! my $AddCounter = 0;
  my $LastAddedTemplateID;
+ 
  TEMPLATE:
! for my $Item ( @{$ItemData} ) {
  
!     if ( $Item->{Add} ) {
  
          # add new template
!         my $TemplateID = $Self->{ImportExportObject}->TemplateAdd( %{ $Item->{Add} } );
  
          if ($TemplateID) {
***************
*** 348,381 ****
  
          # check if template was added successfully or not
!         if ( $Template->{AddGet} ) {
              $Self->True(
                  $TemplateID,
!                 "#$IteratorCounter TemplateAdd() - TemplateKey: $TemplateID"
              );
          }
          else {
!             $Self->False( $TemplateID, "#$IteratorCounter TemplateAdd()" );
          }
      }
  
!     if ( $Template->{AddGet} ) {
  
          # get template data to check the values after template was added
          my $TemplateGet = $Self->{ImportExportObject}->TemplateGet(
              TemplateID => $LastAddedTemplateID,
!             UserID => $Template->{Add}->{UserID} || 1,
          );
  
          # check template data after creation of template
!         for my $TemplateAttribute ( keys %{ $Template->{AddGet} } ) {
              $Self->Is(
                  $TemplateGet->{$TemplateAttribute} || '',
!                 $Template->{AddGet}->{$TemplateAttribute} || '',
!                 "#$IteratorCounter TemplateGet() - $TemplateAttribute",
              );
          }
      }
  
!     if ( $Template->{Update} ) {
  
          # check last template id varaible
--- 333,366 ----
  
          # check if template was added successfully or not
!         if ( $Item->{AddGet} ) {
              $Self->True(
                  $TemplateID,
!                 "Test $TestCount: TemplateAdd() - TemplateKey: $TemplateID"
              );
          }
          else {
!             $Self->False( $TemplateID, "Test $TestCount: TemplateAdd()" );
          }
      }
  
!     if ( $Item->{AddGet} ) {
  
          # get template data to check the values after template was added
          my $TemplateGet = $Self->{ImportExportObject}->TemplateGet(
              TemplateID => $LastAddedTemplateID,
!             UserID => $Item->{Add}->{UserID} || 1,
          );
  
          # check template data after creation of template
!         for my $TemplateAttribute ( keys %{ $Item->{AddGet} } ) {
              $Self->Is(
                  $TemplateGet->{$TemplateAttribute} || '',
!                 $Item->{AddGet}->{$TemplateAttribute} || '',
!                 "Test $TestCount: TemplateGet() - $TemplateAttribute",
              );
          }
      }
  
!     if ( $Item->{Update} ) {
  
          # check last template id varaible
***************
*** 383,387 ****
              $Self->False(
                  1,
!                 "#$IteratorCounter NO LAST ITEM ID GIVEN. Please add a template first."
              );
              last TEMPLATE;
--- 368,372 ----
              $Self->False(
                  1,
!                 "Test $TestCount: NO LAST ITEM ID GIVEN. Please add a template first."
              );
              last TEMPLATE;
***************
*** 390,423 ****
          # update the template
          my $UpdateSucess = $Self->{ImportExportObject}->TemplateUpdate(
!             %{ $Template->{Update} },
              TemplateID => $LastAddedTemplateID,
          );
  
          # check if template was updated successfully or not
!         if ( $Template->{UpdateGet} ) {
              $Self->True(
                  $UpdateSucess,
!                 "#$IteratorCounter TemplateUpdate() - TemplateKey: $LastAddedTemplateID",
              );
          }
          else {
!             $Self->False( $UpdateSucess, "#$IteratorCounter TemplateUpdate()" );
          }
      }
  
!     if ( $Template->{UpdateGet} ) {
  
          # get template data to check the values after the update
          my $TemplateGet = $Self->{ImportExportObject}->TemplateGet(
              TemplateID => $LastAddedTemplateID,
!             UserID => $Template->{Update}->{UserID} || 1,
          );
  
          # check template data after update
!         for my $TemplateAttribute ( keys %{ $Template->{UpdateGet} } ) {
              $Self->Is(
                  $TemplateGet->{$TemplateAttribute} || '',
!                 $Template->{UpdateGet}->{$TemplateAttribute} || '',
!                 "#$IteratorCounter: TemplateGet() - $TemplateAttribute",
              );
          }
--- 375,411 ----
          # update the template
          my $UpdateSucess = $Self->{ImportExportObject}->TemplateUpdate(
!             %{ $Item->{Update} },
              TemplateID => $LastAddedTemplateID,
          );
  
          # check if template was updated successfully or not
!         if ( $Item->{UpdateGet} ) {
              $Self->True(
                  $UpdateSucess,
!                 "Test $TestCount: TemplateUpdate() - TemplateKey: $LastAddedTemplateID",
              );
          }
          else {
!             $Self->False(
!                 $UpdateSucess,
!                 "Test $TestCount: TemplateUpdate()",
!             );
          }
      }
  
!     if ( $Item->{UpdateGet} ) {
  
          # get template data to check the values after the update
          my $TemplateGet = $Self->{ImportExportObject}->TemplateGet(
              TemplateID => $LastAddedTemplateID,
!             UserID => $Item->{Update}->{UserID} || 1,
          );
  
          # check template data after update
!         for my $TemplateAttribute ( keys %{ $Item->{UpdateGet} } ) {
              $Self->Is(
                  $TemplateGet->{$TemplateAttribute} || '',
!                 $Item->{UpdateGet}->{$TemplateAttribute} || '',
!                 "Test $TestCount: TemplateGet() - $TemplateAttribute",
              );
          }
***************
*** 427,440 ****
  
      # increment the counter
!     $IteratorCounter++;
  }
  
  # ------------------------------------------------------------ #
! # TemplateList() test #2
  # ------------------------------------------------------------ #
  
! # get template list
  my $TemplateList2 = $Self->{ImportExportObject}->TemplateList(
-     Object => $ObjectName[0],
      UserID => 1,
  );
--- 415,451 ----
  
      # increment the counter
!     $TestCount++;
  }
  
  # ------------------------------------------------------------ #
! # TemplateList test 1 (check array references)
  # ------------------------------------------------------------ #
  
! # list must be an empty array reference
! $Self->True(
!     ref $TemplateList1All eq 'ARRAY' && ref $TemplateList1Object eq 'ARRAY',
!     "Test $TestCount: TemplateList() - array references",
! );
! 
! $TestCount++;
! 
! # ------------------------------------------------------------ #
! # TemplateList test 2 (list must be empty)
! # ------------------------------------------------------------ #
! 
! # list must be an empty list
! $Self->True(
!     scalar @{$TemplateList1Object} eq 0,
!     "Test $TestCount: TemplateList() - empty list",
! );
! 
! $TestCount++;
! 
! # ------------------------------------------------------------ #
! # TemplateList test 2 (check correct number of new items)
! # ------------------------------------------------------------ #
! 
! # get template list with all elements
  my $TemplateList2 = $Self->{ImportExportObject}->TemplateList(
      UserID => 1,
  );
***************
*** 442,492 ****
  # list must be an array reference
  $Self->True(
!     ref $TemplateList2 eq 'ARRAY' && scalar @{$TemplateList2} eq $AddCounter,
!     "#2 TemplateList()",
  );
  
  # ------------------------------------------------------------ #
! # TemplateDelete() tests
  # ------------------------------------------------------------ #
  
! # delete the first template
! my $Success1 = $Self->{ImportExportObject}->TemplateDelete(
!     TemplateID => shift @{$TemplateList2},
!     UserID     => 1,
  );
  
! # list must be an empty array reference
  $Self->True(
!     $Success1,
!     "#1 TemplateDelete()",
  );
  
! # delete the last template
! my $Success2 = $Self->{ImportExportObject}->TemplateDelete(
!     TemplateID => $TemplateList2,
      UserID     => 1,
  );
  
! # list must be an empty array reference
  $Self->True(
!     $Success2,
!     "#2 TemplateDelete()",
  );
  
  # ------------------------------------------------------------ #
! # TemplateList() test #3
  # ------------------------------------------------------------ #
  
! # get template list
! my $TemplateList3 = $Self->{ImportExportObject}->TemplateList(
!     Object => $ObjectName[0],
!     UserID => 1,
  );
  
! # list must be an empty array reference
  $Self->True(
!     ref $TemplateList3 eq 'ARRAY' && scalar @{$TemplateList3} eq 0,
!     "#3 TemplateList() - empty array reference",
  );
  
  1;
--- 453,646 ----
  # list must be an array reference
  $Self->True(
!     ref $TemplateList2 eq 'ARRAY',
!     "Test $TestCount: TemplateList() - array reference",
  );
  
+ my $TemplateListCount = scalar @{$TemplateList2} - scalar @{$TemplateList1All};
+ 
+ # check correct number of new items
+ $Self->True(
+     $TemplateListCount eq $AddCounter,
+     "Test $TestCount: TemplateList() - correct number of new items",
+ );
+ 
+ $TestCount++;
+ 
  # ------------------------------------------------------------ #
! # TemplateDelete test 1 (add one template and delete it)
  # ------------------------------------------------------------ #
  
! # get template list with all elements
! my $TemplateDelete1List1 = $Self->{ImportExportObject}->TemplateList(
!     Object => $ObjectName[0],
!     UserID => 1,
  );
  
! # add a test template
! my $TemplateDeleteID = $Self->{ImportExportObject}->TemplateAdd(
!     Object  => $ObjectName[0],
!     Format  => $FormatName[0],
!     Name    => $TemplateName[4],
!     ValidID => 1,
!     UserID  => 1,
! );
! 
! # get template list with all elements
! my $TemplateDelete1List2 = $Self->{ImportExportObject}->TemplateList(
!     Object => $ObjectName[0],
!     UserID => 1,
! );
! 
! # list must have one more element
  $Self->True(
!     scalar @{$TemplateDelete1List1} eq ( scalar @{$TemplateDelete1List2} ) - 1,
!     "Test $TestCount: TemplateDelete() - number of listed elements",
  );
  
! # delete the new template
! my $TemplateDelete1 = $Self->{ImportExportObject}->TemplateDelete(
!     TemplateID => $TemplateDeleteID,
      UserID     => 1,
  );
  
! # list must be successfull
  $Self->True(
!     $TemplateDelete1,
!     "Test $TestCount: TemplateDelete()",
! );
! 
! # get template list with all elements
! my $TemplateDelete1List3 = $Self->{ImportExportObject}->TemplateList(
!     Object => $ObjectName[0],
!     UserID => 1,
  );
  
+ # list must have the original number of elements
+ $Self->True(
+     scalar @{$TemplateDelete1List1} eq scalar @{$TemplateDelete1List3},
+     "Test $TestCount: TemplateDelete() - number of listed elements",
+ );
+ 
+ $TestCount++;
+ 
  # ------------------------------------------------------------ #
! # ObjectList test 1 (check general functionality)
  # ------------------------------------------------------------ #
  
! # define test list
! my $ObjectList1TestList = {
!     UnitTest1 => {
!         Module => 'Kernel::System::ImportExport::ObjectBackend::UnitTest1',
!         Name   => 'Unit Test 1',
!     },
!     UnitTest2 => {
!         Module => 'Kernel::System::ImportExport::ObjectBackend::UnitTest2',
!         Name   => 'Unit Test 2',
!     },
! };
! 
! # get original object list
! my $ObjectListOrg = $Self->{ConfigObject}->Get('ImportExport::ObjectBackendRegistration');
! 
! # set test list
! $Self->{ConfigObject}->Set(
!     Key   => 'ImportExport::ObjectBackendRegistration',
!     Value => $ObjectList1TestList,
  );
  
! # get object list
! my $ObjectList1 = $Self->{ImportExportObject}->ObjectList();
! 
! # list must be a hash reference
  $Self->True(
!     ref $ObjectList1 eq 'HASH',
!     "Test $TestCount: ObjectList() - hash reference",
! );
! 
! # check the list
! KEY:
! for my $Key ( keys %{$ObjectList1} ) {
! 
!     if ( !$ObjectList1TestList->{$Key} ) {
!         $ObjectList1TestList->{Dummy} = 1;
!     }
! 
!     next KEY if $ObjectList1->{$Key} ne $ObjectList1TestList->{$Key}->{Name};
! 
!     delete $ObjectList1TestList->{$Key};
! }
! 
! $Self->True(
!     !%{$ObjectList1TestList},
!     "Test $TestCount: ObjectList() - content is valid",
! );
! 
! # restore original object list
! $Self->{ConfigObject}->Set(
!     Key   => 'ImportExport::ObjectBackendRegistration',
!     Value => $ObjectListOrg,
! );
! 
! $TestCount++;
! 
! # ------------------------------------------------------------ #
! # FormatList test 1 (check general functionality)
! # ------------------------------------------------------------ #
! 
! # define test list
! my $FormatList1TestList = {
!     UnitTest1 => {
!         Module => 'Kernel::System::ImportExport::FormatBackend::UnitTest1',
!         Name   => 'Unit Test 1',
!     },
!     UnitTest2 => {
!         Module => 'Kernel::System::ImportExport::FormatBackend::UnitTest2',
!         Name   => 'Unit Test 2',
!     },
! };
! 
! # get original format list
! my $FormatListOrg = $Self->{ConfigObject}->Get('ImportExport::FormatBackendRegistration');
! 
! # set test list
! $Self->{ConfigObject}->Set(
!     Key   => 'ImportExport::FormatBackendRegistration',
!     Value => $FormatList1TestList,
! );
! 
! # get format list
! my $FormatList1 = $Self->{ImportExportObject}->FormatList();
! 
! # list must be a hash reference
! $Self->True(
!     ref $FormatList1 eq 'HASH',
!     "Test $TestCount: FormatList() - hash reference",
  );
  
+ # check the list
+ KEY:
+ for my $Key ( keys %{$FormatList1} ) {
+ 
+     if ( !$FormatList1TestList->{$Key} ) {
+         $FormatList1TestList->{Dummy} = 1;
+     }
+ 
+     next KEY if $FormatList1->{$Key} ne $FormatList1TestList->{$Key}->{Name};
+ 
+     delete $FormatList1TestList->{$Key};
+ }
+ 
+ $Self->True(
+     !%{$FormatList1TestList},
+     "Test $TestCount: FormatList() - content is valid",
+ );
+ 
+ # restore original format list
+ $Self->{ConfigObject}->Set(
+     Key   => 'ImportExport::FormatBackendRegistration',
+     Value => $FormatListOrg,
+ );
+ 
+ $TestCount++;
+ 
  1;


More information about the cvs-log mailing list