Completed
Push — master ( 96a033...7625bb )
by Henry
07:07
created

CommentTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Redaxscript\Tests\View;
3
4
use Redaxscript\Db;
5
use Redaxscript\Tests\TestCaseAbstract;
6
use Redaxscript\View;
7
8
/**
9
 * CommentTest
10
 *
11
 * @since 4.2.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\View\Comment
18
 * @covers Redaxscript\View\ViewAbstract
19
 */
20
21
class CommentTest 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();
0 ignored issues
show
Bug introduced by redaxmedia
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\View\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...
33
		$installer->init();
34
		$installer->rawCreate();
35
		$articleOne = Db::forTablePrefix('articles')->create();
36
		$articleOne
37
			->set(
38
			[
39
				'title' => 'Article One',
40
				'alias' => 'article-one'
41
			])
42
			->save();
43
		$articleTwo = Db::forTablePrefix('articles')->create();
44
		$articleTwo
45
			->set(
46
			[
47
				'title' => 'Article Two',
48
				'alias' => 'article-two'
49
			])
50
			->save();
51
		Db::forTablePrefix('comments')
52
			->create()
53
			->set(
54
			[
55
				'author' => 'Comment One',
56
				'text' => 'Comment One',
57
				'article' => $articleOne->id
58
			])
59
			->save();
60
		Db::forTablePrefix('comments')
61
			->create()
62
			->set(
63
			[
64
				'author' => 'Comment Two',
65
				'text' => 'Comment Two',
66
				'article' => $articleTwo->id
67
			])
68
			->save();
69
		Db::forTablePrefix('comments')
70
			->create()
71
			->set(
72
			[
73
				'author' => 'Comment Two',
74
				'text' => 'Comment Two',
75
				'article' => $articleTwo->id,
76
				'access' => '[1]'
77
			])
78
			->save();
79
	}
80
81
	/**
82
	 * tearDown
83
	 *
84
	 * @since 4.2.0
85
	 */
86
87
	public function tearDown() : void
88
	{
89
		$this->dropDatabase();
0 ignored issues
show
Bug introduced by redaxmedia
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\View\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...
90
	}
91
92
	/**
93
	 * testRender
94
	 *
95
	 * @since 4.2.0
96
	 *
97
	 * @param array $registryArray
98
	 * @param array $optionArray
99
	 * @param int $articleId
100
	 * @param string $expect
101
	 *
102
	 * @dataProvider providerAutoloader
103
	 */
104
105
	public function testRender(array $registryArray = [], array $optionArray = [], int $articleId = null, string $expect = null) : void
106
	{
107
		/* setup */
108
109
		$this->_registry->init($registryArray);
110
		$comment = new View\Comment($this->_registry, $this->_language);
111
		$comment->init($optionArray);
112
113
		/* actual */
114
115
		$actual = $comment->render($articleId);
116
117
		/* compare */
118
119
		$this->assertEquals($expect, $actual);
120
	}
121
}
122