[BUGFIX] Allow subclasses of \DateTime as entity properties
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Persistence / Generic / Mapper / DataMapperTest.php
index 2b58db5..815c268 100644 (file)
@@ -241,6 +241,24 @@ class DataMapperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
+       public function mapDateTimeHandlesSubclassesOfDateTime() {
+               $accessibleClassName = $this->buildAccessibleProxy(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class);
+
+               /** @var DataMapper|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject $accessibleDataMapFactory */
+               $accessibleDataMapFactory = new $accessibleClassName();
+               $targetType = 'TYPO3\CMS\Extbase\Tests\Unit\Persistence\Fixture\Model\CustomDateTime';
+               $date = '2013-01-01 01:02:03';
+               $storageFormat = 'datetime';
+
+               /** @var $dateTime NULL|\DateTime */
+               $dateTime = $accessibleDataMapFactory->_callRef('mapDateTime', $date, $storageFormat, $targetType);
+
+               $this->assertInstanceOf($targetType, $dateTime);
+       }
+
+       /**
+        * @test
+        */
        public function getPlainValueReturnsCorrectDateTimeFormat() {
                $subject = new DataMapper();
                $columnMap = new ColumnMap('column_name', 'propertyName');