[BUGFIX] Fix incomplete mocking in DataMapFactoryTest 28/24628/2
authorAlexander Schnitzler <alex.schnitzler@typovision.de>
Sat, 12 Oct 2013 12:22:54 +0000 (14:22 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 12 Oct 2013 21:45:14 +0000 (23:45 +0200)
Using "expects" on $mockDataMapFactory may fail with
several methods like "setOneToOneRelation" as these methods
return a ColumnMap object but the mock doesn't.

This patch adds the missing "->will($this->return())"
for these methods.

Releases: 6.2
Resolves: #52724
Change-Id: Ic91a7c51b1451c039e20b8ac310fdb25b02e1d84
Reviewed-on: https://review.typo3.org/24628
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapFactoryTest.php

index d3c4332..c70b731 100644 (file)
@@ -55,7 +55,7 @@ class DataMapFactoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        'elementType' => NULL
                );
                $mockDataMapFactory = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array('setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'), array(), '', FALSE);
-               $mockDataMapFactory->expects($this->once())->method('setOneToOneRelation');
+               $mockDataMapFactory->expects($this->once())->method('setOneToOneRelation')->will($this->returnValue($mockColumnMap));
                $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
                $mockDataMapFactory->expects($this->never())->method('setManyToManyRelation');
                $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
@@ -122,7 +122,7 @@ class DataMapFactoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockDataMapFactory = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array('setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'), array(), '', FALSE);
                $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
                $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
-               $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation');
+               $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation')->will($this->returnValue($mockColumnMap));
                $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
        }
 
@@ -143,7 +143,7 @@ class DataMapFactoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                );
                $mockDataMapFactory = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array('setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'), array(), '', FALSE);
                $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
-               $mockDataMapFactory->expects($this->once())->method('setOneToManyRelation');
+               $mockDataMapFactory->expects($this->once())->method('setOneToManyRelation')->will($this->returnValue($mockColumnMap));
                $mockDataMapFactory->expects($this->never())->method('setManyToManyRelation');
                $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
        }
@@ -165,7 +165,7 @@ class DataMapFactoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockDataMapFactory = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array('setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'), array(), '', FALSE);
                $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
                $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
-               $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation');
+               $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation')->will($this->returnValue($mockColumnMap));
                $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
        }
 
@@ -186,7 +186,7 @@ class DataMapFactoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockDataMapFactory = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array('setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'), array(), '', FALSE);
                $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
                $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
-               $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation');
+               $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation')->will($this->returnValue($mockColumnMap));
                $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
        }