* fixed a bug in where clause
authorJochen Rau <j.rau@web.de>
Thu, 19 Feb 2009 10:57:22 +0000 (10:57 +0000)
committerJochen Rau <j.rau@web.de>
Thu, 19 Feb 2009 10:57:22 +0000 (10:57 +0000)
* added some more unit tests for the Data Map

typo3/sysext/extbase/Classes/Persistence/Mapper/TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper.php
typo3/sysext/extbase/Tests/TX_EXTMVC_Persistence_Mapper_DataMap_testcase.php

index 11271a6..d405eed 100644 (file)
@@ -138,7 +138,7 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
                        $object = $this->reconstituteObject($dataMap->getClassName(), $properties);
                        foreach ($dataMap->getColumnMaps() as $columnMap) {
                                if ($columnMap->getTypeOfRelation() === TX_EXTMVC_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
-                                       $where .= $columnMap->getParentKeyFieldName() . '=' . intval($object->getUid());
+                                       $where = $columnMap->getParentKeyFieldName() . '=' . intval($object->getUid());
                                        $relatedDataMap = $this->getDataMap($columnMap->getChildClassName());
                                        $relatedRows = $this->fetch($relatedDataMap, $where);
                                        $relatedObjects = $this->reconstituteObjects($relatedDataMap, $relatedRows, $depth);
index e53bc92..ee2cdbc 100644 (file)
@@ -135,5 +135,42 @@ class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends tx_phpunit_testcase
                $this->assertEquals(11, count($columnMaps), 'The data map was not initialized (wrong number of column maps set).');
        }
        
+       public function test_DeletedColumnNameCanBeResolved() {
+               $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
+               $deletedColumnName = $dataMap->getDeletedColumnName();
+               $this->assertEquals($deletedColumnName, 'deleted', 'The deleted column name could not be resolved.');
+       }
+       
+       public function test_HiddenColumnNameCanBeResolved() {
+               $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
+               $hiddenColumnName = $dataMap->getHiddenColumnName();
+               $this->assertEquals($hiddenColumnName, 'hidden', 'The hidden column name could not be resolved.');
+       }
+       
+       public function test_CloumnCanBeAdded() {
+               $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
+               $dataMap->addColumn('test_column');
+               $columnMaps = $dataMap->getColumnMaps();
+               $columnMap = array_pop($columnMaps);
+               $this->assertType('TX_EXTMVC_Persistence_Mapper_ColumnMap', $columnMap, 'The column could not be added.');
+       }
+       
+       public function test_CloumnListCanBeRetrieved() {
+               $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
+               $dataMap->addColumn('column1');
+               $dataMap->addColumn('column2');
+               $dataMap->addColumn('column3');
+               $dataMap->addColumn('column4');
+               $columnList = $dataMap->getColumnList();
+               $this->assertEquals($columnList, 'column1,column2,column3,column4', 'The column list could not be retrieved.');
+       }
+       
+       public function test_PersistablePropertyCanBeChecked() {
+               $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
+               $dataMap->addColumn('configured_property');
+               $this->assertTrue($dataMap->isPersistableProperty('configuredProperty'), 'The persistable property was marked as unpersistable.');
+               $this->assertFalse($dataMap->isPersistableProperty('unconfiguredProperty'), 'The unpersistable property was marked asersistable.');
+       }
+       
 }
 ?>
\ No newline at end of file