Completed
Push — master ( 1da492...320203 )
by Henry
07:00
created

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

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 = $this->getOptionArray();
0 ignored issues
show
The method getOptionArray() 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...
35
		$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...
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
				'date' => 1483225200
47
			])
48
			->save();
49
		$articleOne = Db::forTablePrefix('articles')->create();
50
		$articleOne
51
			->set(
52
			[
53
				'title' => 'Article One',
54
				'alias' => 'article-one',
55
				'keywords' => 'article, one',
56
				'category' => $categoryOne->id,
57
				'date' => 1483225200
58
			])
59
			->save();
60
		Db::forTablePrefix('comments')
61
			->create()
62
			->set(
63
			[
64
				'author' => 'Comment One',
65
				'text' => 'comment-one',
66
				'article' => $articleOne->id,
67
				'date' => 1451602800
68
			])
69
			->save();
70
	}
71
72
	/**
73
	 * tearDown
74
	 *
75
	 * @since 3.1.0
76
	 */
77
78
	public function tearDown() : void
79
	{
80
		$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...
81
	}
82
83
	/**
84
	 * testRender
85
	 *
86
	 * @since 3.0.0
87
	 *
88
	 * @param array $searchArray
89
	 * @param string $expect
90
	 *
91
	 * @dataProvider providerAutoloader
92
	 */
93
94
	public function testRender(array $searchArray = [], string $expect = null) : void
95
	{
96
		/* setup */
97
98
		$resultList = new View\ResultList($this->_registry, $this->_language);
99
		$controllerSearch = new Controller\Search($this->_registry, $this->_request, $this->_language, $this->_config);
100
		$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...
101
		[
102
			$searchArray
103
		]);
104
105
		/* actual */
106
107
		$actual = $resultList->render($resultArray);
108
109
		/* compare */
110
111
		$this->assertEquals($expect, $actual);
112
	}
113
}
114