c0a9822e2f9605f60923ad7921730b0340b5c535
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Persistence / Generic / Typo3QuerySettingsTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Anja Leichsenring <anja.leichsenring@typo3.org>
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 class Typo3QuerySettingsTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
31
32 /**
33 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings
34 */
35 protected $typo3QuerySettings;
36
37 /**
38 * setup test environment
39 */
40 public function setUp() {
41 $this->typo3QuerySettings = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings', array('dummy'));
42 }
43
44 /**
45 * @return array
46 */
47 public function booleanValueProvider() {
48 return array(
49 'TRUE setting' => array(TRUE),
50 'FALSE setting' => array(FALSE)
51 );
52 }
53
54 /**
55 * @return array
56 */
57 public function arrayValueProvider() {
58 return array(
59 'empty array' => array(array()),
60 'two elements associative' => array(
61 array(
62 'one' => '42',
63 21 => 12
64 )
65 ),
66 'three elements' => array(
67 array(
68 1,
69 'dummy',
70 array()
71 )
72 )
73 );
74 }
75
76 /**
77 * @test
78 * @dataProvider booleanValueProvider
79 * @param boolean $input
80 */
81 public function setRespectStoragePageSetsRespectStoragePageCorrectly($input) {
82 $this->typo3QuerySettings->setRespectStoragePage($input);
83 $this->assertEquals($input, $this->typo3QuerySettings->getRespectStoragePage());
84 }
85
86 /**
87 * @test
88 */
89 public function setRespectStoragePageAllowsChaining() {
90 $this->assertTrue($this->typo3QuerySettings->setRespectStoragePage(TRUE) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
91 }
92
93 /**
94 * @test
95 * @dataProvider arrayValueProvider
96 *
97 * @param array $input
98 */
99 public function setStoragePageIdsSetsStoragePageIdsCorrectly($input) {
100 $this->typo3QuerySettings->setStoragePageIds($input);
101 $this->assertEquals($input, $this->typo3QuerySettings->getStoragePageIds());
102 }
103
104 /**
105 * @test
106 */
107 public function setStoragePageIdsAllowsChaining() {
108 $this->assertTrue($this->typo3QuerySettings->setStoragePageIds(array(1,2,3)) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
109 }
110
111 /**
112 * @test
113 * @dataProvider booleanValueProvider
114 *
115 * @param boolean $input
116 */
117 public function setRespectSysLanguageSetsRespectSysLanguageCorrectly($input) {
118 $this->typo3QuerySettings->setRespectSysLanguage($input);
119 $this->assertEquals($input, $this->typo3QuerySettings->getRespectSysLanguage());
120 }
121
122 /**
123 * @test
124 */
125 public function setRespectSysLanguageAllowsChaining() {
126 $this->assertTrue($this->typo3QuerySettings->setRespectSysLanguage(TRUE) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
127 }
128
129 /**
130 * @test
131 */
132 public function setLanguageUidAllowsChaining() {
133 $this->assertTrue($this->typo3QuerySettings->setLanguageUid(42) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
134 }
135
136 /**
137 * @test
138 * @dataProvider booleanValueProvider
139 *
140 * @param boolean $input
141 */
142 public function setRespectEnableFieldsSetsRespectEnableFieldsCorrectly($input) {
143 $this->typo3QuerySettings->setRespectEnableFields($input);
144 $this->assertEquals($input, $this->typo3QuerySettings->getRespectEnableFields());
145 }
146
147 /**
148 * @test
149 */
150 public function setRespectEnableFieldsAllowsChaining() {
151 $this->assertTrue($this->typo3QuerySettings->setRespectEnableFields(TRUE) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
152 }
153
154 /**
155 * @test
156 * @dataProvider booleanValueProvider
157 *
158 * @param boolean $input
159 */
160 public function setIgnoreEnableFieldsSetsIgnoreEnableFieldsCorrectly($input) {
161 $this->typo3QuerySettings->setIgnoreEnableFields($input);
162 $this->assertEquals($input, $this->typo3QuerySettings->getIgnoreEnableFields());
163 }
164
165 /**
166 * @test
167 */
168 public function setIgnoreEnableFieldsAllowsChaining() {
169 $this->assertTrue($this->typo3QuerySettings->setIgnoreEnableFields(TRUE) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
170 }
171
172 /**
173 * @test
174 * @dataProvider arrayValueProvider
175 *
176 * @param array $input
177 */
178 public function setEnableFieldsToBeIgnoredSetsEnableFieldsToBeIgnoredCorrectly($input) {
179 $this->typo3QuerySettings->setEnableFieldsToBeIgnored($input);
180 $this->assertEquals($input, $this->typo3QuerySettings->getEnableFieldsToBeIgnored());
181 }
182
183 /**
184 * @test
185 */
186 public function setEnableFieldsToBeIgnoredAllowsChaining() {
187 $this->assertTrue($this->typo3QuerySettings->setEnableFieldsToBeIgnored(array('starttime', 'endtime')) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
188 }
189
190 /**
191 * @test
192 * @dataProvider booleanValueProvider
193 *
194 * @param boolean $input
195 */
196 public function setIncludeDeletedSetsIncludeDeletedCorrectly($input) {
197 $this->typo3QuerySettings->setIncludeDeleted($input);
198 $this->assertEquals($input, $this->typo3QuerySettings->getIncludeDeleted());
199 }
200
201 /**
202 * @test
203 */
204 public function setIncludeDeletedAllowsChaining() {
205 $this->assertTrue($this->typo3QuerySettings->setIncludeDeleted(TRUE) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
206 }
207
208 /**
209 * @test
210 * @dataProvider booleanValueProvider
211 *
212 * @param boolean $input
213 */
214 public function setReturnRawQueryResultSetsReturnRawQueryResultCorrectly($input) {
215 $this->typo3QuerySettings->setReturnRawQueryResult($input);
216 $this->assertEquals($input, $this->typo3QuerySettings->getReturnRawQueryResult());
217 }
218
219 /**
220 * @test
221 */
222 public function setReturnRawQueryResultAllowsChaining() {
223 $this->assertTrue($this->typo3QuerySettings->setReturnRawQueryResult(TRUE) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface);
224 }
225 }