1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\View\Helper; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Db; |
5
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
6
|
|
|
use Redaxscript\View\Helper\Breadcrumb; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* BreadcrumbTest |
10
|
|
|
* |
11
|
|
|
* @since 2.1.0 |
12
|
|
|
* |
13
|
|
|
* @package Redaxscript |
14
|
|
|
* @category Tests |
15
|
|
|
* @author Henry Ruhs |
16
|
|
|
* @author Gary Aylward |
17
|
|
|
* |
18
|
|
|
* @covers Redaxscript\View\Helper\Breadcrumb |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
class BreadcrumbTest extends TestCaseAbstract |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* setUp |
25
|
|
|
* |
26
|
|
|
* @since 3.1.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
|
|
|
]) |
44
|
|
|
->save(); |
45
|
|
|
$categoryTwo = Db::forTablePrefix('categories')->create(); |
46
|
|
|
$categoryTwo |
47
|
|
|
->set( |
48
|
|
|
[ |
49
|
|
|
'title' => 'Category Two', |
50
|
|
|
'alias' => 'category-two', |
51
|
|
|
'parent' => $categoryOne->id |
52
|
|
|
]) |
53
|
|
|
->save(); |
54
|
|
|
Db::forTablePrefix('articles') |
55
|
|
|
->create() |
56
|
|
|
->set( |
57
|
|
|
[ |
58
|
|
|
'title' => 'Article One', |
59
|
|
|
'alias' => 'article-one', |
60
|
|
|
'category' => $categoryOne->id |
61
|
|
|
]) |
62
|
|
|
->save(); |
63
|
|
|
Db::forTablePrefix('articles') |
64
|
|
|
->create() |
65
|
|
|
->set( |
66
|
|
|
[ |
67
|
|
|
'title' => 'Article Two', |
68
|
|
|
'alias' => 'article-two', |
69
|
|
|
'category' => $categoryTwo->id |
70
|
|
|
]) |
71
|
|
|
->save(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* tearDown |
76
|
|
|
* |
77
|
|
|
* @since 3.1.0 |
78
|
|
|
*/ |
79
|
|
|
|
80
|
|
|
public function tearDown() : void |
81
|
|
|
{ |
82
|
|
|
$this->dropDatabase(); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* testGetArray |
87
|
|
|
* |
88
|
|
|
* @since 2.1.0 |
89
|
|
|
* |
90
|
|
|
* @param array $registryArray |
91
|
|
|
* @param array $expectArray |
92
|
|
|
* |
93
|
|
|
* @dataProvider providerAutoloader |
94
|
|
|
*/ |
95
|
|
|
|
96
|
|
|
public function testGetArray(array $registryArray = [], array $expectArray = []) : void |
97
|
|
|
{ |
98
|
|
|
/* setup */ |
99
|
|
|
|
100
|
|
|
$this->_registry->init($registryArray); |
101
|
|
|
$breadcrumb = new Breadcrumb($this->_registry, $this->_language); |
102
|
|
|
$breadcrumb->init(); |
103
|
|
|
|
104
|
|
|
/* actual */ |
105
|
|
|
|
106
|
|
|
$actualArray = $breadcrumb->getArray(); |
107
|
|
|
|
108
|
|
|
/* compare */ |
109
|
|
|
|
110
|
|
|
$this->assertEquals($expectArray, $actualArray); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* testRender |
115
|
|
|
* |
116
|
|
|
* @since 2.1.0 |
117
|
|
|
* |
118
|
|
|
* @param array $registryArray |
119
|
|
|
* @param string $expect |
120
|
|
|
* |
121
|
|
|
* @dataProvider providerAutoloader |
122
|
|
|
*/ |
123
|
|
|
|
124
|
|
|
public function testRender(array $registryArray = [], string $expect = null) : void |
125
|
|
|
{ |
126
|
|
|
/* setup */ |
127
|
|
|
|
128
|
|
|
$this->_registry->init($registryArray); |
129
|
|
|
$breadcrumb = new Breadcrumb($this->_registry, $this->_language); |
130
|
|
|
$breadcrumb->init(); |
131
|
|
|
|
132
|
|
|
/* actual */ |
133
|
|
|
|
134
|
|
|
$actual = $breadcrumb; |
135
|
|
|
|
136
|
|
|
/* compare */ |
137
|
|
|
|
138
|
|
|
$this->assertEquals($expect, $actual); |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.