[BUGFIX] Fix incomplete mocking in ResourceStorage test 08/17508/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 13 Jan 2013 17:24:51 +0000 (18:24 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 13 Jan 2013 17:26:07 +0000 (18:26 +0100)
Due to a not mocked FileRepository object, a warning
is issued which leads to a failed test.

Add a FileRepository mock and clean up all usage
of the FileRepository in ResourceStorage.

Fixes: #44439
Releases: 6.0, 6.1

Change-Id: I214fce4635d452764bd9edc8e11f863bd76961a6
Reviewed-on: https://review.typo3.org/17508
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php

index 63f0996..1ffb7b2 100644 (file)
@@ -864,9 +864,7 @@ class ResourceStorage {
        public function getFileList($path, $start = 0, $numberOfItems = 0, $useFilters = TRUE, $loadIndexRecords = TRUE, $recursive = FALSE) {
                $rows = array();
                if ($loadIndexRecords) {
-                       /** @var $repository \TYPO3\CMS\Core\Resource\FileRepository */
-                       $repository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-                       $rows = $repository->getFileIndexRecordsForFolder($this->getFolder($path));
+                       $rows = $this->getFileRepository()->getFileIndexRecordsForFolder($this->getFolder($path));
                }
                $filters = $useFilters == TRUE ? $this->fileAndFolderNameFilters : array();
                $items = $this->driver->getFileList($path, $start, $numberOfItems, $filters, $rows, $recursive);
@@ -1227,9 +1225,7 @@ class ResourceStorage {
                try {
                        $newIdentifier = $this->driver->renameFile($file, $targetFileName);
                        $this->updateFile($file, $newIdentifier);
-                       /** @var $fileRepository \TYPO3\CMS\Core\Resource\FileRepository */
-                       $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-                       $fileRepository->update($file);
+                       $this->getFileRepository()->update($file);
                } catch (\RuntimeException $e) {
 
                }
index 36dbb04..d162790 100644 (file)
@@ -47,6 +47,11 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
                parent::setUp();
                $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
                \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(
+                       'TYPO3\\CMS\\Core\\Resource\\FileRepository',
+                       $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository')
+               );
+
        }
 
        public function tearDown() {