[BUGFIX] Tests: Incomplete mocking in be_user 96/28196/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 9 Mar 2014 15:31:45 +0000 (16:31 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 9 Mar 2014 15:55:06 +0000 (16:55 +0100)
ModuleDataStorageServiceTest now mocks $GLOBALS['BE_USER']
to not rely on instantiation of this global.

Change-Id: I5ab6b962d95f2ab183dfc1b1b53dea7deaa464c5
Resolves: #56687
Related: #51436
Releases: 6.2
Reviewed-on: https://review.typo3.org/28196
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/beuser/Tests/Unit/Service/ModuleDataStorageServiceTest.php

index 1283b24..77714b0 100644 (file)
@@ -27,7 +27,7 @@ namespace TYPO3\CMS\Beuser\Tests\Unit\Service;
  ***************************************************************/
 
 /**
- * Test case for class \TYPO3\CMS\Beuser\Service\ModuleDataStorageService
+ * Test case
  *
  * @author Felix Kopp <felix-source@phorax.com>
  * @author Nikolas Hagelstein <nikolas.hagelstein@gmail.com>
@@ -35,22 +35,16 @@ namespace TYPO3\CMS\Beuser\Tests\Unit\Service;
 class ModuleDataStorageServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
-        * @var \TYPO3\CMS\Beuser\Service\ModuleDataStorageService
-        */
-       protected $fixture;
-
-       public function setUp() {
-               $this->fixture = $this->objectManager->get('TYPO3\\CMS\\Beuser\\Service\\ModuleDataStorageService');
-       }
-
-       /**
         * @test
         */
        public function loadModuleDataReturnsModuleDataObjectForEmptyModuleData() {
                // Simulate empty module data
-               unset($GLOBALS['BE_USER']->uc['moduleData'][\TYPO3\CMS\Beuser\Service\ModuleDataStorageService::KEY]);
-               $result = $this->fixture->loadModuleData();
-               $this->assertInstanceOf('TYPO3\\CMS\\Beuser\\Domain\\Model\\ModuleData', $result);
-       }
+               $GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(), array(), '', FALSE);
+               $GLOBALS['BE_USER']->uc = array();
+               $GLOBALS['BE_USER']->uc['moduleData'] = array();
 
+               /** @var \TYPO3\CMS\Beuser\Service\ModuleDataStorageService $subject */
+               $subject = $this->objectManager->get('TYPO3\\CMS\\Beuser\\Service\\ModuleDataStorageService');
+               $this->assertInstanceOf('TYPO3\\CMS\\Beuser\\Domain\\Model\\ModuleData', $subject->loadModuleData());
+       }
 }