Merge branch 'pu/2013.03/modelconfig-hr' into pu/2013.03-modelconfig-hr/inventory
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 3 Jun 2013 11:12:39 +0000 (13:12 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 3 Jun 2013 11:12:39 +0000 (13:12 +0200)
1  2 
tests/tine20/Inventory/Import/CsvTest.php
tine20/Inventory/Model/InventoryItem.php
tine20/Tinebase/Import/Abstract.php

@@@ -146,31 -148,28 +148,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
@@@ -76,9 -76,9 +76,10 @@@ class Inventory_Model_InventoryItem ext
              'invoice_date' => array(
                  'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
                  'label'      => 'Invoice date', // _('Invoice date')
 +                'inputFilters' => array('Zend_Filter_Empty' => NULL),
                  'hidden'     => TRUE,
-                 'default'    => NULL
+                 'default'    => NULL,
+                 'inputFilters' => array('Zend_Filter_Empty' => NULL),
              ),
              'total_number' => array(
                  'validators' => array(Zend_Filter_Input::ALLOW_EMPTY => true),
Simple merge