[BUGFIX] FollowUp to "Invalid localization overlay of cObject FILES" 66/30666/4
authorSteffen Ritter <info@rs-websystems.de>
Wed, 11 Jun 2014 15:48:28 +0000 (17:48 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 11 Jun 2014 20:41:34 +0000 (22:41 +0200)
When fixing language overlay of cObject FILES, the mocking in the unit
test was not adapted.

Resolves: #58352
Resolves: #47869
Releases: 6.2
Change-Id: I8f939e31a13e437e437624dfccddf5f39526fb8b
Reviewed-on: https://review.typo3.org/30666
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Tests/Unit/Resource/Service/FrontendContentAdapterServiceTest.php

index 5aa31ea..f85443d 100644 (file)
@@ -28,38 +28,31 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Service;
  */
 class FrontendContentAdapterServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
-        * @var \PHPUnit_Framework_MockObject_MockObject
-        */
-       protected $fileRepositoryMock;
-
        /**
         * @var array A backup of registered singleton instances
         */
        protected $singletonInstances = array();
 
        /**
-        * Saving the singletons
+        * @var \TYPO3\CMS\Frontend\Page\PageRepository|\PHPUnit_Framework_MockObject_MockObject
         */
-       public function setUp() {
-               $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-               $this->fileRepositoryMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository');
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository', $this->fileRepositoryMock);
-       }
+       protected $pageRepositoryMock;
 
        /**
-        * Restoring the singletons
+        * Saving the singletons
         */
-       public function tearDown() {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-               parent::tearDown();
+       public function setUp() {
+               $this->pageRepositoryMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
+               $GLOBALS['TSFE'] = new \stdClass;
+               $GLOBALS['TSFE']->sys_page = $this->pageRepositoryMock;
        }
 
        /**
         * @test
         */
        public function emptyRelationResetsLegacyFields() {
-               $this->fileRepositoryMock->expects($this->any())
-                       ->method('findByRelation')
+               $this->pageRepositoryMock->expects($this->any())
+                       ->method('getFileReferences')
                        ->will($this->returnValue(array()));
                $dbRow = array(
                        'CType' => 'image',
@@ -81,8 +74,8 @@ class FrontendContentAdapterServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCa
                $fileReference->expects($this->any())
                        ->method('getPublicUrl')
                        ->will($this->returnValue('path/to/file'));
-               $this->fileRepositoryMock->expects($this->any())
-                       ->method('findByRelation')
+               $this->pageRepositoryMock->expects($this->any())
+                       ->method('getFileReferences')
                        ->will($this->returnValue(array($fileReference)));
                $dbRow = array(
                        'CType' => 'image',
@@ -150,8 +143,8 @@ class FrontendContentAdapterServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCa
                $fileReference->expects($this->any())
                        ->method('getPublicUrl')
                        ->will($this->returnValue('path/to/file'));
-               $this->fileRepositoryMock->expects($this->any())
-                       ->method('findByRelation')
+               $this->pageRepositoryMock->expects($this->any())
+                       ->method('getFileReferences')
                        ->will($this->returnValue(array($fileReference)));
 
                \TYPO3\CMS\Core\Resource\Service\FrontendContentAdapterService::modifyDBRow($dbRow, 'tt_content');