1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\View; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Controller; |
5
|
|
|
use Redaxscript\Db; |
6
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
7
|
|
|
use Redaxscript\View; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* ResultListTest |
11
|
|
|
* |
12
|
|
|
* @since 3.0.0 |
13
|
|
|
* |
14
|
|
|
* @package Redaxscript |
15
|
|
|
* @category Tests |
16
|
|
|
* @author Henry Ruhs |
17
|
|
|
* @author Balázs Szilágyi |
18
|
|
|
* |
19
|
|
|
* @covers Redaxscript\View\ResultList |
20
|
|
|
* @covers Redaxscript\View\ViewAbstract |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
class ResultListTest extends TestCaseAbstract |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* setUp |
27
|
|
|
* |
28
|
|
|
* @since 3.1.0 |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
public function setUp() : void |
32
|
|
|
{ |
33
|
|
|
parent::setUp(); |
34
|
|
|
$optionArray = $this->getOptionArray(); |
35
|
|
|
$installer = $this->installerFactory(); |
36
|
|
|
$installer->init(); |
37
|
|
|
$installer->rawCreate(); |
38
|
|
|
$installer->insertSettings($optionArray); |
39
|
|
|
$categoryOne = Db::forTablePrefix('categories')->create(); |
40
|
|
|
$categoryOne |
41
|
|
|
->set( |
42
|
|
|
[ |
43
|
|
|
'title' => 'Category One', |
44
|
|
|
'alias' => 'category-one', |
45
|
|
|
'keywords' => 'category, one', |
46
|
|
|
'language' => 'en', |
47
|
|
|
'date' => 1483225200 |
48
|
|
|
]) |
49
|
|
|
->save(); |
50
|
|
|
$articleOne = Db::forTablePrefix('articles')->create(); |
51
|
|
|
$articleOne |
52
|
|
|
->set( |
53
|
|
|
[ |
54
|
|
|
'title' => 'Article One', |
55
|
|
|
'alias' => 'article-one', |
56
|
|
|
'keywords' => 'article, one', |
57
|
|
|
'language' => 'en', |
58
|
|
|
'category' => $categoryOne->id, |
59
|
|
|
'date' => 1483225200 |
60
|
|
|
]) |
61
|
|
|
->save(); |
62
|
|
|
Db::forTablePrefix('comments') |
63
|
|
|
->create() |
64
|
|
|
->set( |
65
|
|
|
[ |
66
|
|
|
'author' => 'Comment One', |
67
|
|
|
'text' => 'Comment One', |
68
|
|
|
'language' => 'en', |
69
|
|
|
'article' => $articleOne->id, |
70
|
|
|
'date' => 1451602800 |
71
|
|
|
]) |
72
|
|
|
->save(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* tearDown |
77
|
|
|
* |
78
|
|
|
* @since 3.1.0 |
79
|
|
|
*/ |
80
|
|
|
|
81
|
|
|
public function tearDown() : void |
82
|
|
|
{ |
83
|
|
|
$this->dropDatabase(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* testRender |
88
|
|
|
* |
89
|
|
|
* @since 3.0.0 |
90
|
|
|
* |
91
|
|
|
* @param array $searchArray |
92
|
|
|
* @param string $expect |
93
|
|
|
* |
94
|
|
|
* @dataProvider providerAutoloader |
95
|
|
|
*/ |
96
|
|
|
|
97
|
|
|
public function testRender(array $searchArray = [], string $expect = null) : void |
98
|
|
|
{ |
99
|
|
|
/* setup */ |
100
|
|
|
|
101
|
|
|
$resultList = new View\ResultList($this->_registry, $this->_language); |
102
|
|
|
$controllerSearch = new Controller\Search($this->_registry, $this->_request, $this->_language, $this->_config); |
103
|
|
|
$resultArray = $this->callMethod($controllerSearch, '_search', |
104
|
|
|
[ |
105
|
|
|
$searchArray |
106
|
|
|
]); |
107
|
|
|
|
108
|
|
|
/* actual */ |
109
|
|
|
|
110
|
|
|
$actual = $resultList->render($resultArray); |
111
|
|
|
|
112
|
|
|
/* compare */ |
113
|
|
|
|
114
|
|
|
$this->assertEquals($expect, $actual); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|