[BUGFIX] Tests: Incomplete mocking in ext:beuser 75/28275/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 11 Mar 2014 20:37:41 +0000 (21:37 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 11 Mar 2014 20:57:03 +0000 (21:57 +0100)
The module data storage test subject calls several static
dependencies that can not be mocked without code refactoring. Those
dependencies do database stuff in the end, so DB needs to be properly
mocked for this test.

Change-Id: Id882b3a3a785940b5499c9afeff67f193c480e3b
Resolves: #56791
Related: #51436
Releases: 6.2
Reviewed-on: https://review.typo3.org/28275
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/beuser/Tests/Unit/Service/ModuleDataStorageServiceTest.php

index 77714b0..1f6bd2b 100644 (file)
@@ -38,6 +38,10 @@ class ModuleDataStorageServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTes
         * @test
         */
        public function loadModuleDataReturnsModuleDataObjectForEmptyModuleData() {
+               // The test calls several static dependencies that can not be mocked and
+               // call database in the end, so we need to mock the database here.
+               $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
+
                // Simulate empty module data
                $GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(), array(), '', FALSE);
                $GLOBALS['BE_USER']->uc = array();