[BUGFIX] Fix failing test 86/22586/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 26 Jul 2013 09:21:45 +0000 (11:21 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 26 Jul 2013 10:03:47 +0000 (12:03 +0200)
The test failes due to incorrect mocking, what leads to not claimed
properties for the test.
Additionally the expected call amounts where handled more strictly
where fitting.

Releases: 6.2, 6.1, 6.0
Resolves: #50458
Change-Id: I34214fb9ef9e9935892aa03518505b877538e128
Reviewed-on: https://review.typo3.org/22586
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php

index 080f51a..0fb851e 100644 (file)
@@ -427,8 +427,8 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @test
         */
        public function uidOfAlreadyPersistedValueObjectIsDeterminedCorrectly() {
-               $mockValueObject = $this->getMockForAbstractClass('TYPO3\\CMS\\Extbase\\DomainObject\\AbstractValueObject', array('_getProperties'), '', FALSE);
-               $mockValueObject->expects($this->any())->method('_getProperties')->will($this->returnValue(array('propertyName' => 'propertyValue')));
+               $mockValueObject = $this->getMock('TYPO3\\CMS\\Extbase\\DomainObject\\AbstractValueObject', array('_getProperties'), array(), '', FALSE);
+               $mockValueObject->expects($this->once())->method('_getProperties')->will($this->returnValue(array('propertyName' => 'propertyValue')));
                $mockColumnMap = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMap', array('isPersistableProperty', 'getColumnName'), array(), '', FALSE);
                $mockColumnMap->expects($this->any())->method('getColumnName')->will($this->returnValue('column_name'));
                $tableName = 'tx_foo_table';
@@ -437,7 +437,7 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockDataMap->expects($this->any())->method('getColumnMap')->will($this->returnValue($mockColumnMap));
                $mockDataMap->expects($this->any())->method('getTableName')->will($this->returnValue($tableName));
                $mockDataMapper = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapper', array('getDataMap'), array(), '', FALSE);
-               $mockDataMapper->expects($this->any())->method('getDataMap')->will($this->returnValue($mockDataMap));
+               $mockDataMapper->expects($this->once())->method('getDataMap')->will($this->returnValue($mockDataMap));
                $expectedStatement = 'SELECT * FROM tx_foo_table WHERE column_name=?';
                $expectedParameters = array('plainPropertyValue');
                $expectedUid = 52;
@@ -447,7 +447,7 @@ class Typo3DbBackendTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockTypo3DbBackend = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend', array('getPlainValue', 'checkSqlErrors', 'replacePlaceholders', 'addVisibilityConstraintStatement'), array(), '', FALSE);
                $mockTypo3DbBackend->expects($this->once())->method('getPlainValue')->will($this->returnValue('plainPropertyValue'));
                $mockTypo3DbBackend->expects($this->once())->method('addVisibilityConstraintStatement')->with($this->isInstanceOf('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface'), $tableName, $this->isType('array'));
-               $mockTypo3DbBackend->expects($this->once())->method('replacePlaceholders')->with($expectedStatement, $expectedParameters)->will($this->returnValue('plainPropertyValue'));
+               $mockTypo3DbBackend->expects($this->once())->method('replacePlaceholders')->with($expectedStatement, $expectedParameters);
                $mockTypo3DbBackend->_set('dataMapper', $mockDataMapper);
                $mockTypo3DbBackend->_set('databaseHandle', $mockDataBaseHandle);
                $result = $mockTypo3DbBackend->_callRef('getUidOfAlreadyPersistedValueObject', $mockValueObject);