1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\View; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Db; |
5
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
6
|
|
|
use Redaxscript\View; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* ArticleTest |
10
|
|
|
* |
11
|
|
|
* @since 4.2.0 |
12
|
|
|
* |
13
|
|
|
* @package Redaxscript |
14
|
|
|
* @category Tests |
15
|
|
|
* @author Henry Ruhs |
16
|
|
|
* |
17
|
|
|
* @covers Redaxscript\View\Article |
18
|
|
|
* @covers Redaxscript\View\ViewAbstract |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
class ArticleTest extends TestCaseAbstract |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* setUp |
25
|
|
|
* |
26
|
|
|
* @since 4.2.0 |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
public function setUp() : void |
30
|
|
|
{ |
31
|
|
|
parent::setUp(); |
32
|
|
|
$installer = $this->installerFactory(); |
|
|
|
|
33
|
|
|
$installer->init(); |
34
|
|
|
$installer->rawCreate(); |
35
|
|
|
$categoryOne = Db::forTablePrefix('categories')->create(); |
36
|
|
|
$categoryOne |
37
|
|
|
->set( |
38
|
|
|
[ |
39
|
|
|
'title' => 'Category One', |
40
|
|
|
'alias' => 'category-one' |
41
|
|
|
]) |
42
|
|
|
->save(); |
43
|
|
|
$categoryTwo = Db::forTablePrefix('categories')->create(); |
44
|
|
|
$categoryTwo |
45
|
|
|
->set( |
46
|
|
|
[ |
47
|
|
|
'title' => 'Category Two', |
48
|
|
|
'alias' => 'category-two' |
49
|
|
|
]) |
50
|
|
|
->save(); |
51
|
|
|
$articleOne = Db::forTablePrefix('articles')->create(); |
52
|
|
|
$articleOne |
53
|
|
|
->set( |
54
|
|
|
[ |
55
|
|
|
'title' => 'Article One', |
56
|
|
|
'alias' => 'article-one', |
57
|
|
|
'text' => 'Article One', |
58
|
|
|
'category' => $categoryOne->id |
59
|
|
|
]) |
60
|
|
|
->save(); |
61
|
|
|
$articleTwo = Db::forTablePrefix('articles')->create(); |
62
|
|
|
$articleTwo |
63
|
|
|
->set( |
64
|
|
|
[ |
65
|
|
|
'title' => 'Article Two', |
66
|
|
|
'alias' => 'article-two', |
67
|
|
|
'text' => 'Article Two', |
68
|
|
|
'category' => $categoryOne->id |
69
|
|
|
]) |
70
|
|
|
->save(); |
71
|
|
|
$articleThree = Db::forTablePrefix('articles')->create(); |
72
|
|
|
$articleThree |
73
|
|
|
->set( |
74
|
|
|
[ |
75
|
|
|
'title' => 'Article Three', |
76
|
|
|
'alias' => 'article-three', |
77
|
|
|
'text' => 'Article Three', |
78
|
|
|
'category' => $categoryTwo->id |
79
|
|
|
]) |
80
|
|
|
->save(); |
81
|
|
|
$articleFour = Db::forTablePrefix('articles')->create(); |
82
|
|
|
$articleFour |
83
|
|
|
->set( |
84
|
|
|
[ |
85
|
|
|
'title' => 'Article Four', |
86
|
|
|
'alias' => 'article-four', |
87
|
|
|
'text' => 'Article Four', |
88
|
|
|
'access' => '[1]' |
89
|
|
|
]) |
90
|
|
|
->save(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* tearDown |
95
|
|
|
* |
96
|
|
|
* @since 4.2.0 |
97
|
|
|
*/ |
98
|
|
|
|
99
|
|
|
public function tearDown() : void |
100
|
|
|
{ |
101
|
|
|
$this->dropDatabase(); |
|
|
|
|
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* testRender |
106
|
|
|
* |
107
|
|
|
* @since 4.2.0 |
108
|
|
|
* |
109
|
|
|
* @param array $registryArray |
110
|
|
|
* @param array $optionArray |
111
|
|
|
* @param int $categoryId |
112
|
|
|
* @param int $articleId |
113
|
|
|
* @param string $expect |
114
|
|
|
* |
115
|
|
|
* @dataProvider providerAutoloader |
116
|
|
|
*/ |
117
|
|
|
|
118
|
|
|
public function testRender(array $registryArray = [], array $optionArray = [], int $categoryId = null, int $articleId = null, string $expect = null) : void |
119
|
|
|
{ |
120
|
|
|
/* setup */ |
121
|
|
|
|
122
|
|
|
$this->_registry->init($registryArray); |
123
|
|
|
$article = new View\Article($this->_registry, $this->_request, $this->_language, $this->_config); |
124
|
|
|
$article->init($optionArray); |
125
|
|
|
|
126
|
|
|
/* actual */ |
127
|
|
|
|
128
|
|
|
$actual = $article->render($categoryId, $articleId); |
129
|
|
|
|
130
|
|
|
/* compare */ |
131
|
|
|
|
132
|
|
|
$this->assertEquals($expect, $actual); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
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.