CategoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 89
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 40 1
A tearDown() 0 4 1
A testRender() 0 16 1
1
<?php
2
namespace Redaxscript\Tests\Navigation;
3
4
use Redaxscript\Db;
5
use Redaxscript\Navigation;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * CategoryTest
10
 *
11
 * @since 3.3.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Navigation\Category
18
 * @covers Redaxscript\Navigation\NavigationAbstract
19
 */
20
21
class CategoryTest extends TestCaseAbstract
22
{
23
	/**
24
	 * setUp
25
	 *
26
	 * @since 3.3.0
27
	 */
28
29
	public function setUp() : void
30
	{
31
		parent::setUp();
32
		$optionArray = $this->getOptionArray();
33
		$installer = $this->installerFactory();
34
		$installer->init();
35
		$installer->rawCreate();
36
		$installer->insertSettings($optionArray);
37
		$categoryOne = Db::forTablePrefix('categories')->create();
38
		$categoryOne
39
			->set(
40
			[
41
				'title' => 'Category One',
42
				'alias' => 'category-one',
43
				'rank' => 1,
44
				'status' => 1
45
			])
46
			->save();
47
		$categoryTwo = Db::forTablePrefix('categories')->create();
48
		$categoryTwo
49
			->set(
50
			[
51
				'title' => 'Category Two',
52
				'alias' => 'category-two',
53
				'rank' => 2,
54
				'status' => 1
55
			])
56
			->save();
57
		$categoryTwo = Db::forTablePrefix('categories')->create();
58
		$categoryTwo
59
			->set(
60
			[
61
				'title' => 'Category Three',
62
				'alias' => 'category-three',
63
				'parent' => $categoryOne->id,
64
				'rank' => 2,
65
				'status' => 1
66
			])
67
			->save();
68
	}
69
70
	/**
71
	 * tearDown
72
	 *
73
	 * @since 3.3.0
74
	 */
75
76
	public function tearDown() : void
77
	{
78
		$this->dropDatabase();
79
	}
80
81
	/**
82
	 * testRender
83
	 *
84
	 * @since 3.3.0
85
	 *
86
	 * @param array $registryArray
87
	 * @param array $optionArray
88
	 * @param string $expect
89
	 *
90
	 * @dataProvider providerAutoloader
91
	 */
92
93
	public function testRender(array $registryArray = [], array $optionArray = [], string $expect = null) : void
94
	{
95
		/* setup */
96
97
		$this->_registry->init($registryArray);
98
		$navigation = new Navigation\Category($this->_registry, $this->_language);
99
		$navigation->init($optionArray);
100
101
		/* actual */
102
103
		$actual = $navigation;
104
105
		/* compare */
106
107
		$this->assertEquals($expect, $actual);
108
	}
109
}
110