[BUGFIX] Follow-up: Split sys_file table to extract metadata 94/24694/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 13 Oct 2013 12:20:39 +0000 (14:20 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 13 Oct 2013 12:22:55 +0000 (14:22 +0200)
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
typo3/sysext/core/Tests/Unit/Resource/FileTest.php

index 495e43c..42d1c24 100644 (file)
@@ -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');
        }
 
        /**