Completed
Push — master ( 0947c3...b8ee92 )
by Henry
11:06 queued 03:27
created

OptionTest::testGetZoneArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Redaxscript\Tests\Admin\View\Helper;
3
4
use Redaxscript\Admin\View\Helper;
5
use Redaxscript\Db;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * OptionTest
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Admin\View\Helper\Option
18
 */
19
20
class OptionTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 3.1.0
26
	 */
27
28
	public function setUp()
29
	{
30
		parent::setUp();
31
		$optionArray =
32
		[
33
			'adminName' => 'Test',
34
			'adminUser' => 'test',
35
			'adminPassword' => 'test',
36
			'adminEmail' => '[email protected]'
37
		];
38
		$installer = $this->installerFactory();
39
		$installer->init();
40
		$installer->rawCreate();
41
		$installer->insertSettings($optionArray);
42
		Db::forTablePrefix('articles')
43
			->create()
44
			->set(
45
			[
46
				'title' => 'Article One',
47
				'alias' => 'article-one'
48
			])
49
			->save();
50
		Db::forTablePrefix('articles')
51
			->create()
52
			->set(
53
			[
54
				'title' => 'Article Two',
55
				'alias' => 'article-two'
56
			])
57
			->save();
58
		Db::forTablePrefix('articles')
59
			->create()
60
			->set(
61
			[
62
				'title' => 'Article Three',
63
				'alias' => 'article-three'
64
			])
65
			->save();
66
		Db::forTablePrefix('groups')
67
			->create()
68
			->set(
69
			[
70
				'name' => 'Group One',
71
				'alias' => 'group-one'
72
			])
73
			->save();
74
		Db::forTablePrefix('groups')
75
			->create()
76
			->set(
77
			[
78
				'name' => 'Group Two',
79
				'alias' => 'group-two'
80
			])
81
			->save();
82
	}
83
84
	/**
85
	 * tearDown
86
	 *
87
	 * @since 3.1.0
88
	 */
89
90
	public function tearDown()
91
	{
92
		$this->dropDatabase();
93
	}
94
95
	/**
96
	 * testGetToggleArray
97
	 *
98
	 * @since 3.0.0
99
	 *
100
	 * @param array $expectArray
101
	 *
102
	 * @dataProvider providerAutoloader
103
	 */
104
105
	public function testGetToggleArray(array $expectArray = [])
106
	{
107
		/* setup */
108
109
		$helperOption = new Helper\Option($this->_language);
110
111
		/* actual */
112
113
		$actualArray = $helperOption->getToggleArray();
114
115
		/* compare */
116
117
		$this->assertEquals($expectArray['toggle'], $actualArray);
118
	}
119
120
	/**
121
	 * testGetVisibleArray
122
	 *
123
	 * @since 3.0.0
124
	 *
125
	 * @param array $expectArray
126
	 *
127
	 * @dataProvider providerAutoloader
128
	 */
129
130
	public function testGetVisibleArray(array $expectArray = [])
131
	{
132
		/* setup */
133
134
		$helperOption = new Helper\Option($this->_language);
135
136
		/* actual */
137
138
		$actualArray = $helperOption->getVisibleArray();
139
140
		/* compare */
141
142
		$this->assertEquals($expectArray['visible'], $actualArray);
143
	}
144
145
	/**
146
	 * testGetRobotArray
147
	 *
148
	 * @since 3.0.0
149
	 *
150
	 * @param array $expectArray
151
	 *
152
	 * @dataProvider providerAutoloader
153
	 */
154
155
	public function testGetRobotArray(array $expectArray = [])
156
	{
157
		/* setup */
158
159
		$helperOption = new Helper\Option($this->_language);
160
161
		/* actual */
162
163
		$actualArray = $helperOption->getRobotArray();
164
165
		/* compare */
166
167
		$this->assertEquals($expectArray['robot'], $actualArray);
168
	}
169
170
	/**
171
	 * testGetZoneArray
172
	 *
173
	 * @since 4.0.0
174
	 */
175
176
	public function testGetZoneArray()
177
	{
178
		/* setup */
179
180
		$helperOption = new Helper\Option($this->_language);
181
182
		/* actual */
183
184
		$actualArray = $helperOption->getZoneArray();
185
186
		/* compare */
187
188
		$this->assertContains('UTC', $actualArray);
189
	}
190
191
	/**
192
	 * testGetTimeArray
193
	 *
194
	 * @since 3.0.0
195
	 *
196
	 * @param array $expectArray
197
	 *
198
	 * @dataProvider providerAutoloader
199
	 */
200
201
	public function testGetTimeArray(array $expectArray = [])
202
	{
203
		/* setup */
204
205
		$helperOption = new Helper\Option($this->_language);
206
207
		/* actual */
208
209
		$actualArray = $helperOption->getTimeArray();
210
211
		/* compare */
212
213
		$this->assertEquals($expectArray['time'], $actualArray);
214
	}
215
216
	/**
217
	 * testGetDateArray
218
	 *
219
	 * @since 3.0.0
220
	 *
221
	 * @param array $expectArray
222
	 *
223
	 * @dataProvider providerAutoloader
224
	 */
225
226
	public function testGetDateArray(array $expectArray = [])
227
	{
228
		/* setup */
229
230
		$helperOption = new Helper\Option($this->_language);
231
232
		/* actual */
233
234
		$actualArray = $helperOption->getDateArray();
235
236
		/* compare */
237
238
		$this->assertEquals($expectArray['date'], $actualArray);
239
	}
240
241
	/**
242
	 * testGetOrderArray
243
	 *
244
	 * @since 3.0.0
245
	 *
246
	 * @param array $expectArray
247
	 *
248
	 * @dataProvider providerAutoloader
249
	 */
250
251
	public function testGetOrderArray(array $expectArray = [])
252
	{
253
		/* setup */
254
255
		$helperOption = new Helper\Option($this->_language);
256
257
		/* actual */
258
259
		$actualArray = $helperOption->getOrderArray();
260
261
		/* compare */
262
263
		$this->assertEquals($expectArray['order'], $actualArray);
264
	}
265
266
	/**
267
	 * testGetCaptchaArray
268
	 *
269
	 * @since 3.0.0
270
	 *
271
	 * @param array $expectArray
272
	 *
273
	 * @dataProvider providerAutoloader
274
	 */
275
276
	public function testGetCaptchaArray(array $expectArray = [])
277
	{
278
		/* setup */
279
280
		$helperOption = new Helper\Option($this->_language);
281
282
		/* actual */
283
284
		$actualArray = $helperOption->getCaptchaArray();
285
286
		/* compare */
287
288
		$this->assertEquals($expectArray['captcha'], $actualArray);
289
	}
290
291
	/**
292
	 * testGetPermissionArray
293
	 *
294
	 * @since 3.0.0
295
	 *
296
	 * @param array $expectArray
297
	 *
298
	 * @dataProvider providerAutoloader
299
	 */
300
301
	public function testGetPermissionArray(array $expectArray = [])
302
	{
303
		/* setup */
304
305
		$helperOption = new Helper\Option($this->_language);
306
307
		/* actual */
308
309
		$actualArray =
310
		[
311
			'content' => $helperOption->getPermissionArray(),
312
			'module' => $helperOption->getPermissionArray('modules'),
313
			'setting' => $helperOption->getPermissionArray('settings')
314
		];
315
316
		/* compare */
317
318
		$this->assertEquals($expectArray['permission']['content'], $actualArray['content']);
319
		$this->assertEquals($expectArray['permission']['module'], $actualArray['module']);
320
		$this->assertEquals($expectArray['permission']['setting'], $actualArray['setting']);
321
	}
322
323
	/**
324
	 * testGetLanguageArray
325
	 *
326
	 * @since 3.0.0
327
	 *
328
	 * @param array $expectArray
329
	 *
330
	 * @dataProvider providerAutoloader
331
	 */
332
333
	public function testGetLanguageArray(array $expectArray = [])
334
	{
335
		/* setup */
336
337
		$helperOption = new Helper\Option($this->_language);
338
339
		/* actual */
340
341
		$actualArray = $helperOption->getLanguageArray();
342
343
		/* compare */
344
345
		$this->assertTrue(!array_diff($expectArray['language'], $actualArray));
346
	}
347
348
	/**
349
	 * testGetTemplateArray
350
	 *
351
	 * @since 3.0.0
352
	 *
353
	 * @param array $expectArray
354
	 *
355
	 * @dataProvider providerAutoloader
356
	 */
357
358
	public function testGetTemplateArray(array $expectArray = [])
359
	{
360
		/* setup */
361
362
		$helperOption = new Helper\Option($this->_language);
363
364
		/* actual */
365
366
		$actualArray = $helperOption->getTemplateArray();
367
368
		/* compare */
369
370
		$this->assertTrue(!array_diff($expectArray['template'], $actualArray));
371
	}
372
373
	/**
374
	 * testGetContentArray
375
	 *
376
	 * @since 3.0.0
377
	 *
378
	 * @param array $expectArray
379
	 *
380
	 * @dataProvider providerAutoloader
381
	 */
382
383
	public function testGetContentArray(array $expectArray = [])
384
	{
385
		/* setup */
386
387
		$helperOption = new Helper\Option($this->_language);
388
389
		/* actual */
390
391
		$actualArray = $helperOption->getContentArray('articles',
392
		[
393
			3,
394
		]);
395
396
		/* compare */
397
398
		$this->assertEquals($expectArray['content'], $actualArray);
399
	}
400
401
	/**
402
	 * testGetAccessArray
403
	 *
404
	 * @since 3.0.0
405
	 *
406
	 * @param array $expectArray
407
	 *
408
	 * @dataProvider providerAutoloader
409
	 */
410
411
	public function testGetAccessArray(array $expectArray = [])
412
	{
413
		/* setup */
414
415
		$helperOption = new Helper\Option($this->_language);
416
417
		/* actual */
418
419
		$actualArray = $helperOption->getAccessArray('groups');
420
421
		/* compare */
422
423
		$this->assertEquals($expectArray['access'], $actualArray);
424
	}
425
}
426