[BUGFIX] Fix tests for old property mapper
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 24 Feb 2013 20:36:30 +0000 (21:36 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 3 Mar 2013 10:13:05 +0000 (11:13 +0100)
The "fix" for failing tests after merging #42622
was to actually not test if the mapping works,
but only if the map method completes without errors.

Re-enable the correct test again.

Fixes: #45682
Releases: 6.1
Change-Id: I8ddabb1fce82f75b379c41aac7c959890f3ff56b
Reviewed-on: https://review.typo3.org/18462
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Property/Mapper.php
typo3/sysext/extbase/Tests/Unit/Property/MapperTest.php

index 8ed6827..2b62782 100644 (file)
@@ -185,11 +185,11 @@ class Mapper implements \TYPO3\CMS\Core\SingletonInterface {
         *
         * @param array $propertyNames Names of the properties to map.
         * @param mixed $source Source containing the properties to map to the target object. Must either be an array, ArrayObject or any other object.
-        * @param object|array $target The target object
+        * @param object|array|string $target The target object
         * @param array $optionalPropertyNames Names of optional properties. If a property is specified here and it doesn't exist in the source, no error is issued.
         * @throws Exception\InvalidSourceException
         * @throws Exception\InvalidTargetException
-        * @return boolean TRUE if the properties could be mapped, otherwise FALSE
+        * @return boolean TRUE if the properties could be mapped, otherwise FALSE, or the object in case it could be resolved
         * @see mapAndValidate()
         * @api
         */
index 35dd8d1..555f0df 100644 (file)
@@ -44,7 +44,7 @@ class MapperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         */
        public function setUp() {
                /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
-               $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+               $objectManager = new \TYPO3\CMS\Extbase\Object\ObjectManager();
 
                /** @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager $persistenceManager */
                $persistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
@@ -59,7 +59,7 @@ class MapperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                /** @var \TYPO3\CMS\Extbase\Validation\ValidatorResolver $validatorResolver */
                $validatorResolver = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver');
 
-               $this->fixture = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Property\\Mapper', array('dummy'));
+               $this->fixture = new \TYPO3\CMS\Extbase\Property\Mapper();
                $this->fixture->injectObjectManager($objectManager);
                $this->fixture->injectPersistenceManager($persistenceManager);
                $this->fixture->injectQueryFactory($queryFactory);
@@ -84,7 +84,7 @@ class MapperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $expectedObject->setProperty1($source['property1']);
                $expectedObject->setProperty2($source['property2']);
 
-               $this->assertTrue($this->fixture->map(array('property1', 'property2'), $source, $expectedObject));
+               $this->assertEquals($expectedObject, $this->fixture->map(array('property1', 'property2'), $source, 'TYPO3\\CMS\\Extbase\\Tests\\Fixture\\ClassWithGettersAndSetters'));
        }
 
        /**
@@ -100,7 +100,7 @@ class MapperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $expectedObject->setProperty1($source['property1']);
                $expectedObject->setProperty2($source['property2']);
 
-               $this->assertTrue($this->fixture->map(array('property1', 'property2'), $source, $expectedObject));
+               $this->assertEquals($expectedObject, $this->fixture->map(array('property1', 'property2'), $source, 'Tx_Extbase_Tests_Fixture_TxClassWithGettersAndSetters'));
        }
 }