Completed
Push — master ( 16ddfb...0ea243 )
by Henry
09:18
created

tests/unit/View/ResultListTest.php (3 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 =
35
		[
36
			'adminName' => 'Test',
37
			'adminUser' => 'test',
38
			'adminPassword' => 'test',
39
			'adminEmail' => '[email protected]'
40
		];
41
		$installer = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\View\ResultListTest>.

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.

Loading history...
42
		$installer->init();
43
		$installer->rawCreate();
44
		$installer->insertSettings($optionArray);
45
		$categoryOne = Db::forTablePrefix('categories')->create();
46
		$categoryOne
47
			->set(
48
			[
49
				'title' => 'Category One',
50
				'alias' => 'category-one',
51
				'date' => 1483225200
52
			])
53
			->save();
54
		$articleOne = Db::forTablePrefix('articles')->create();
55
		$articleOne
56
			->set(
57
			[
58
				'title' => 'Article One',
59
				'alias' => 'article-one',
60
				'category' => $categoryOne->id,
61
				'date' => 1483225200
62
			])
63
			->save();
64
		Db::forTablePrefix('comments')
65
			->create()
66
			->set(
67
			[
68
				'author' => 'Comment One',
69
				'text' => 'Comment One',
70
				'article' => $articleOne->id,
71
				'date' => 1451602800
72
			])
73
			->save();
74
	}
75
76
	/**
77
	 * tearDown
78
	 *
79
	 * @since 3.1.0
80
	 */
81
82
	public function tearDown() : void
83
	{
84
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\View\ResultListTest>.

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.

Loading history...
85
	}
86
87
	/**
88
	 * testRender
89
	 *
90
	 * @since 3.0.0
91
	 *
92
	 * @param array $searchArray
93
	 * @param string $expect
94
	 *
95
	 * @dataProvider providerAutoloader
96
	 */
97
98
	public function testRender(array $searchArray = [], string $expect = null) : void
99
	{
100
		/* setup */
101
102
		$resultList = new View\ResultList($this->_registry, $this->_language);
103
		$controllerSearch = new Controller\Search($this->_registry, $this->_request, $this->_language, $this->_config);
104
		$resultArray = $this->callMethod($controllerSearch, '_search',
0 ignored issues
show
The method callMethod() does not seem to exist on object<Redaxscript\Tests\View\ResultListTest>.

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.

Loading history...
105
		[
106
			$searchArray
107
		]);
108
109
		/* actual */
110
111
		$actual = $resultList->render($resultArray);
112
113
		/* compare */
114
115
		$this->assertEquals($expect, $actual);
116
	}
117
}
118