[+BUGFIX] Extbase (Persistence): Added exception if a data map is built with an unkno...
authorSebastian Kurfürst <sebastian@typo3.org>
Tue, 15 Jun 2010 06:49:50 +0000 (06:49 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Tue, 15 Jun 2010 06:49:50 +0000 (06:49 +0000)
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapFactory.php
typo3/sysext/extbase/Tests/Persistence/Mapper/DataMapFactory_testcase.php

index 6d54f69..aad8a1e 100644 (file)
@@ -55,6 +55,10 @@ class Tx_Extbase_Persistence_Mapper_DataMapFactory {
         * @return Tx_Extbase_Persistence_Mapper_DataMap The data map
         */
        public function buildDataMap($className) {
+               if (!class_exists($className)) {
+                       throw new Tx_Extbase_Persistence_Exception_InvalidClass('Could not find class definition for name "' . $className . '". This could be caused by a mis-spelling of the class name in the class definition.');
+               }
+
                $recordType = NULL;
                $subclasses = array();
                $tableName = strtolower($className);
index 0bfe5c7..a3442c3 100644 (file)
@@ -310,5 +310,14 @@ class Tx_Extbase_Persistence_Mapper_DataMapFactory_testcase extends Tx_Extbase_B
                $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']);
        }
        
+       /**
+        * @test
+        * @expectedException Tx_Extbase_Persistence_Exception_InvalidClass
+        */
+       public function buildDataMapThrowsExceptionIfClassNameIsNotKnown() {
+               $mockDataMapFactory = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Persistence_Mapper_DataMapFactory'), array('getControlSection'), array(), '', FALSE);
+               $mockDataMapFactory->buildDataMap('UnknownObject');
+       }
+       
 }
 ?>
\ No newline at end of file