From 1db78eaf0381e4270c9fce231b5caf0c8a75fb89 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Sun, 13 Oct 2013 14:20:39 +0200 Subject: [PATCH] [BUGFIX] Follow-up: Split sys_file table to extract metadata Two unit tests failed after the patch. This is fixed by rewriting the tests to real unit tests and better mocking. Change-Id: If43b1867d538a330189e0fc8b8041a1192c075a2 Resolves: #52726 Releases: 6.2 Reviewed-on: https://review.typo3.org/24694 Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn --- .../core/Tests/Unit/Resource/FileTest.php | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/typo3/sysext/core/Tests/Unit/Resource/FileTest.php b/typo3/sysext/core/Tests/Unit/Resource/FileTest.php index 495e43c8df8a..42d1c24fa4f2 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/FileTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/FileTest.php @@ -213,28 +213,41 @@ class FileTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { * @test */ public function isIndexedTriggersIndexingIfFileIsNotIndexedAlready() { - $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array('loadMetadata'), array(array('identifier' => '/test', 'storage' => 5), $this->storageMock)); - - $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository'); - $mockedRepository->expects($this->once())->method('findOneByCombinedIdentifier')->will($this->returnValue(FALSE)); - \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository', $mockedRepository); - + $sut = $this->getAccessibleMock( + 'TYPO3\\CMS\\Core\\Resource\\File', + array('loadIndexRecord'), + array(), + '', + FALSE + ); + $sut->_set('indexed', NULL); + $sut->_set('indexingInProgress', FALSE); - $fixture->isIndexed(); + $sut + ->expects($this->once()) + ->method('loadIndexRecord'); + $sut->isIndexed(); } /** * @test */ public function fileIsAutomaticallyIndexedOnPropertyAccessIfNotAlreadyIndexed() { - $fixture = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array('loadMetadata'), array(array('identifier' => '/test', 'storage' => 5), $this->storageMock)); - - $mockedRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository'); - $mockedRepository->expects($this->once())->method('findOneByCombinedIdentifier')->will($this->returnValue(FALSE)); - $mockedRepository->expects($this->once())->method('add'); - \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository', $mockedRepository); - - $fixture->getProperty('uid'); + $sut = $this->getAccessibleMock( + 'TYPO3\\CMS\\Core\\Resource\\File', + array('loadIndexRecord'), + array(), + '', + FALSE + ); + $sut->_set('metaDataProperties', array()); + $sut->_set('properties', array()); + + $sut->_set('indexed', NULL); + $sut + ->expects($this->once()) + ->method('loadIndexRecord'); + $sut->getProperty('foo'); } /** -- GitLab