/** * @test * @dataProvider conteRowsOfDifferentTypesDataProvider */ public function migrationOfLegacyFieldsIsOnlyDoneWhenRelationFieldIsVisibleInType($dbRow, $expectedCaption, $fileProperties) { $fileReference = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileReference', array(), array(), '', FALSE); $fileReference->expects($this->once())->method('getProperties')->will($this->returnValue($fileProperties)); $fileReference->expects($this->any())->method('getOriginalFile')->will($this->returnValue($this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE))); $fileReference->expects($this->any())->method('getPublicUrl')->will($this->returnValue('path/to/file')); $this->pageRepositoryMock->expects($this->any())->method('getFileReferences')->will($this->returnValue(array($fileReference))); \TYPO3\CMS\Core\Resource\Service\FrontendContentAdapterService::modifyDBRow($dbRow, 'tt_content'); $this->assertSame($expectedCaption, $dbRow['imagecaption']); }
/** * @test */ public function enrichWithRelationFieldsCreatesWhereClauseForDisabledField() { $mockDatabaseConnection = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array('exec_SELECTgetRows'), array(), '', false); $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Utility\RootlineUtility::class, array('columnHasRelationToResolve'), array(1, '', $this->pageContextMock)); $subject->_set('databaseConnection', $mockDatabaseConnection); $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = ''; $foreign_table = $this->getUniqueId('foreign_table'); $foreign_field = $this->getUniqueId('foreign_field'); $GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled'] = $this->getUniqueId('disabled'); $GLOBALS['TCA']['pages']['columns'] = array('test' => array('config' => array('foreign_table' => $foreign_table, 'foreign_field' => $foreign_field))); $expected = array($foreign_field . ' = 0', $foreign_table . '.' . $GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled'] . ' = 0'); $this->pageContextMock->expects($this->once())->method('deleteClause')->will($this->returnValue('')); $mockDatabaseConnection->expects($this->once())->method('exec_SELECTgetRows')->with('uid', $foreign_table, implode(' AND ', $expected), '', '', '', '')->will($this->returnValue(array('uid' => 17))); $subject->expects($this->once())->method('columnHasRelationToResolve')->will($this->returnValue(true)); $subject->_call('enrichWithRelationFields', 17, array()); }
/** * Sets up this testcase */ public function setUp() { $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_SELECTquery', 'sql_fetch_assoc', 'sql_free_result')); $this->pageSelectObject = $this->getAccessibleMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository', array('getMultipleGroupsWhereClause')); $this->pageSelectObject->expects($this->any())->method('getMultipleGroupsWhereClause')->will($this->returnValue(' AND 1=1')); }