1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\Navigation; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Db; |
5
|
|
|
use Redaxscript\Navigation; |
6
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* ArticleTest |
10
|
|
|
* |
11
|
|
|
* @since 3.3.0 |
12
|
|
|
* |
13
|
|
|
* @package Redaxscript |
14
|
|
|
* @category Tests |
15
|
|
|
* @author Henry Ruhs |
16
|
|
|
* |
17
|
|
|
* @covers Redaxscript\Navigation\Article |
18
|
|
|
* @covers Redaxscript\Navigation\NavigationAbstract |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
class ArticleTest 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
|
|
|
Db::forTablePrefix('articles') |
58
|
|
|
->create() |
59
|
|
|
->set( |
60
|
|
|
[ |
61
|
|
|
'title' => 'Article One', |
62
|
|
|
'alias' => 'article-one', |
63
|
|
|
'category' => $categoryOne->id, |
64
|
|
|
'rank' => 1, |
65
|
|
|
'status' => 1 |
66
|
|
|
]) |
67
|
|
|
->save(); |
68
|
|
|
Db::forTablePrefix('articles') |
69
|
|
|
->create() |
70
|
|
|
->set( |
71
|
|
|
[ |
72
|
|
|
'title' => 'Article Two', |
73
|
|
|
'alias' => 'article-two', |
74
|
|
|
'category' => $categoryTwo->id, |
75
|
|
|
'rank' => 2, |
76
|
|
|
'status' => 1 |
77
|
|
|
]) |
78
|
|
|
->save(); |
79
|
|
|
Db::forTablePrefix('articles') |
80
|
|
|
->create() |
81
|
|
|
->set( |
82
|
|
|
[ |
83
|
|
|
'title' => 'Article Three', |
84
|
|
|
'alias' => 'article-three', |
85
|
|
|
'rank' => 3, |
86
|
|
|
'status' => 1 |
87
|
|
|
]) |
88
|
|
|
->save(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* tearDown |
93
|
|
|
* |
94
|
|
|
* @since 3.3.0 |
95
|
|
|
*/ |
96
|
|
|
|
97
|
|
|
public function tearDown() : void |
98
|
|
|
{ |
99
|
|
|
$this->dropDatabase(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* testRender |
104
|
|
|
* |
105
|
|
|
* @since 3.3.0 |
106
|
|
|
* |
107
|
|
|
* @param array $registryArray |
108
|
|
|
* @param array $optionArray |
109
|
|
|
* @param string $expect |
110
|
|
|
* |
111
|
|
|
* @dataProvider providerAutoloader |
112
|
|
|
*/ |
113
|
|
|
|
114
|
|
|
public function testRender(array $registryArray = [], array $optionArray = [], string $expect = null) : void |
115
|
|
|
{ |
116
|
|
|
/* setup */ |
117
|
|
|
|
118
|
|
|
$this->_registry->init($registryArray); |
119
|
|
|
$navigation = new Navigation\Article($this->_registry, $this->_language); |
120
|
|
|
$navigation->init($optionArray); |
121
|
|
|
|
122
|
|
|
/* actual */ |
123
|
|
|
|
124
|
|
|
$actual = $navigation; |
125
|
|
|
|
126
|
|
|
/* compare */ |
127
|
|
|
|
128
|
|
|
$this->assertEquals($expect, $actual); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|