[BUGFIX] Tests: Improve mocking in ext:belog 15/28215/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 10 Mar 2014 10:57:53 +0000 (11:57 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 10 Mar 2014 11:15:02 +0000 (12:15 +0100)
The subject method initialize() calls some static dependencies
that can not be mocked. They do DB actions in the end. The patch
now mocks TYPO3_DB to suppress this DB call.

Change-Id: I43b0e002bfab081ed41a5c259011f465b507a74b
Resolves: #56718
Related: #51436
Releases: 6.2
Reviewed-on: https://review.typo3.org/28215
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/belog/Tests/Unit/Domain/Repository/LogEntryRepositoryTest.php

index 5a0087a..2259256 100644 (file)
@@ -23,8 +23,9 @@ namespace TYPO3\CMS\Belog\Tests\Unit\Domain\Repository;
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
- * Testcase
+ * Test case
  *
  * @author Oliver Klee <typo3-coding@oliverklee.de>
  */
@@ -45,10 +46,12 @@ class LogEntryRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
         * @test
         */
        public function initializeObjectSetsRespectStoragePidToFalse() {
+               $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
                $this->querySettings->expects($this->atLeastOnce())->method('setRespectStoragePage')->with(FALSE);
-               $fixture = $this->getMock('TYPO3\\CMS\\Belog\\Domain\\Repository\\LogEntryRepository', array('setDefaultQuerySettings'), array($this->objectManager));
-               $fixture->expects($this->once())->method('setDefaultQuerySettings')->with($this->querySettings);
-               $fixture->initializeObject();
+               /** @var \TYPO3\CMS\Belog\Domain\Repository\LogEntryRepository|\PHPUnit_Framework_MockObject_MockObject $subject */
+               $subject = $this->getMock('TYPO3\\CMS\\Belog\\Domain\\Repository\\LogEntryRepository', array('setDefaultQuerySettings'), array($this->objectManager));
+               $subject->expects($this->once())->method('setDefaultQuerySettings')->with($this->querySettings);
+               $subject->initializeObject();
        }
 
 }