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

tests/unit/Navigation/CommentTest.php (2 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\Navigation;
3
4
use Redaxscript\Db;
5
use Redaxscript\Navigation;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * CommentTest
10
 *
11
 * @since 3.3.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Navigation\Comment
18
 */
19
20
class CommentTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 3.3.0
26
	 */
27
28
	public function setUp() : void
29
	{
30
		parent::setUp();
31
		$optionArray =
32
		[
33
			'adminName' => 'Test',
34
			'adminUser' => 'test',
35
			'adminPassword' => 'test',
36
			'adminEmail' => '[email protected]'
37
		];
38
		$installer = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\Navigation\CommentTest>.

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...
39
		$installer->init();
40
		$installer->rawCreate();
41
		$installer->insertSettings($optionArray);
42
		$articleOne = Db::forTablePrefix('articles')->create();
43
		$articleOne
44
			->set(
45
			[
46
				'title' => 'Article One',
47
				'alias' => 'article-one',
48
				'rank' => 1,
49
				'status' => 1
50
			])
51
			->save();
52
		$articleTwo = Db::forTablePrefix('articles')->create();
53
		$articleTwo
54
			->set(
55
			[
56
				'title' => 'Article One',
57
				'alias' => 'article-one',
58
				'rank' => 2,
59
				'status' => 1
60
			])
61
			->save();
62
		Db::forTablePrefix('comments')
63
			->create()
64
			->set(
65
			[
66
				'author' => 'Comment One',
67
				'text' => 'Comment One',
68
				'article' => $articleOne->id,
69
				'rank' => 1,
70
				'status' => 1
71
			])
72
			->save();
73
		Db::forTablePrefix('comments')
74
			->create()
75
			->set(
76
			[
77
				'author' => 'Comment Two',
78
				'text' => 'Comment Two',
79
				'article' => $articleOne->id,
80
				'rank' => 2,
81
				'status' => 1
82
			])
83
			->save();
84
		Db::forTablePrefix('comments')
85
			->create()
86
			->set(
87
			[
88
				'author' => 'Comment Three',
89
				'text' => 'Comment Three',
90
				'article' => $articleTwo->id,
91
				'rank' => 3,
92
				'status' => 1
93
			])
94
			->save();
95
	}
96
97
	/**
98
	 * tearDown
99
	 *
100
	 * @since 3.3.0
101
	 */
102
103
	public function tearDown() : void
104
	{
105
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\Navigation\CommentTest>.

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...
106
	}
107
108
	/**
109
	 * testRender
110
	 *
111
	 * @since 3.3.0
112
	 *
113
	 * @param array $registryArray
114
	 * @param array $optionArray
115
	 * @param string $expect
116
	 *
117
	 * @dataProvider providerAutoloader
118
	 */
119
120
	public function testRender(array $registryArray = [], array $optionArray = [], string $expect = null) : void
121
	{
122
		/* setup */
123
124
		$this->_registry->init($registryArray);
125
		$navigation = new Navigation\Comment($this->_registry, $this->_language);
126
		$navigation->init($optionArray);
127
128
		/* actual */
129
130
		$actual = $navigation;
131
132
		/* compare */
133
134
		$this->assertEquals($expect, $actual);
135
	}
136
}
137