[BUGFIX] Followup to #51528 15/27215/3
authorFrans Saris <franssaris@gmail.com>
Fri, 31 Jan 2014 19:30:18 +0000 (20:30 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 31 Jan 2014 20:32:54 +0000 (21:32 +0100)
Because of some missing mocking there are
several DB error messages when running the FileTest

This adds the missing mocking of the MetaDataRepository.

Releases: 6.2
Resolves: #51528
Change-Id: I02ccb45d315b3eee045efda96c947fb67fd71d20
Reviewed-on: https://review.typo3.org/27215
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Tests/Unit/Resource/FileTest.php

index 079cc2a..53dbf7a 100644 (file)
@@ -47,6 +47,10 @@ class FileTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
                $this->storageMock = $this->getMock('TYPO3\CMS\Core\Resource\ResourceStorage', array(), array(), '', FALSE);
                $this->storageMock->expects($this->any())->method('getUid')->will($this->returnValue(5));
+
+               $mockedMetaDataRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository');
+               $mockedMetaDataRepository->expects($this->any())->method('findByFile')->will($this->returnValue(array('file' => 1)));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository', $mockedMetaDataRepository);
        }
 
        public function tearDown() {
@@ -119,6 +123,10 @@ class FileTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function fileIndexStatusIsTrueIfUidIsSet() {
+               $mockedMetaDataRepository = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository');
+               $mockedMetaDataRepository->expects($this->once())->method('findByFile')->will($this->returnValue(array('file' => 1)));
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository', $mockedMetaDataRepository);
+
                $fixture = new \TYPO3\CMS\Core\Resource\File(array('uid' => 1), $this->storageMock);
                $this->assertTrue($fixture->isIndexed());
        }