[BUGFIX] Tests: Improve mocking in ext:belog
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / Tests / Unit / Domain / Repository / LogEntryRepositoryTest.php
1 <?php
2 namespace TYPO3\CMS\Belog\Tests\Unit\Domain\Repository;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Oliver Klee <typo3-coding@oliverklee.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Test case
29 *
30 * @author Oliver Klee <typo3-coding@oliverklee.de>
31 */
32 class LogEntryRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
33
34 /**
35 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings
36 */
37 protected $querySettings = NULL;
38
39 public function setUp() {
40 $this->querySettings = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
41 $this->objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
42 $this->objectManager->expects($this->any())->method('get')->with('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface')->will($this->returnValue($this->querySettings));
43 }
44
45 /**
46 * @test
47 */
48 public function initializeObjectSetsRespectStoragePidToFalse() {
49 $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
50 $this->querySettings->expects($this->atLeastOnce())->method('setRespectStoragePage')->with(FALSE);
51 /** @var \TYPO3\CMS\Belog\Domain\Repository\LogEntryRepository|\PHPUnit_Framework_MockObject_MockObject $subject */
52 $subject = $this->getMock('TYPO3\\CMS\\Belog\\Domain\\Repository\\LogEntryRepository', array('setDefaultQuerySettings'), array($this->objectManager));
53 $subject->expects($this->once())->method('setDefaultQuerySettings')->with($this->querySettings);
54 $subject->initializeObject();
55 }
56
57 }