Merge branch 'pu/2013.03-modelconfig-hr/inventory'
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 23 Apr 2013 12:28:37 +0000 (14:28 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 23 Apr 2013 12:28:37 +0000 (14:28 +0200)
1  2 
tests/tine20/Inventory/Import/CsvTest.php

@@@ -146,28 -146,31 +146,52 @@@ class Inventory_Import_CsvTest extends 
          $this->assertEquals($result['results'][1]['inventory_id'], '1333431666');
      }
      
 +     /**
 +     * Test if different Datetime formats are correctly imported, if datetime_pattern is set
 +     */
 +    public function testImportOfDatetimeFormats ()
 +    {
 +        $filename = dirname(__FILE__) . '/files/inv_tine_import_csv_nohook.xml';
 +        $applicationId = Tinebase_Application::getInstance()->getApplicationByName('Inventory')->getId();
 +        $definition = Tinebase_ImportExportDefinition::getInstance()->getFromFile($filename, $applicationId);
 +        
 +        $this->_filename = dirname(__FILE__) . '/files/inv_tine_import_datetimes.csv';
 +        $this->_deleteImportFile = FALSE;
 +        
 +        $result = $this->_doImport(array(), $definition);
 +        $this->_deletePersonalInventoryItems = TRUE;
 +        
 +        $this->assertEquals('2013-12-31 00:00:00', $result['results'][0]['added_date']->setTimezone('Europe/Berlin')->toString(), 'Datetime and datetime_pattern should match');
 +        $this->assertEquals('2013-12-31 00:00:00', $result['results'][0]['removed_date']->setTimezone('Europe/Berlin')->toString(), 'Datetime and datetime_pattern should match');
 +        $this->assertNull($result['results'][1]['added_date'], 'Datetime and datetime_pattern do not match,  therefore should return null');
 +        $this->assertNull( $result['results'][1]['added_date'], 'Datetime and datetime_pattern do not match,  therefore should return null');
 +    }
 +    
      /**
+      * Tests if import of the example file works
+      */
+     public function testImportOfExampleFile ()
+     {
+         $filename = dirname(__FILE__) . '/files/inv_tine_import_csv_nohook.xml';
+         $applicationId = Tinebase_Application::getInstance()->getApplicationByName('Inventory')->getId();
+         $definition = Tinebase_ImportExportDefinition::getInstance()->getFromFile($filename, $applicationId);
+         
+         $this->_filename = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/tine20/Inventory/Import/examples/inv_tine_import.csv'; 
+         $this->_deleteImportFile = FALSE;
+         
+         $result = $this->_doImport(array(), $definition);
+         $this->_deletePersonalInventoryItems = TRUE;
+         
+         $translation = Tinebase_Translation::getTranslation('Tinebase');
+         $translatedString = sprintf($translation->_("The following fields weren't imported: %s"), "\n");
+         
+         $this->assertEquals($result['results'][0]['name'], 'Tine 2.0 für Einsteiger');
+         $this->assertEquals($result['results'][0]['added_date'], '2013-12-06 00:00:00');
+         $this->assertEquals($result['results'][0]['inventory_id'], '133331666');
+         $this->assertContains($translatedString, $result['results'][0]['description']);
+     }
+     
+     /**
       * import helper
       *
       * @param array $_options