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

tests/unit/Admin/Controller/CommentTest.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\Admin\Controller;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Db;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * CommentTest
10
 *
11
 * @since 4.1.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Admin\Controller\Comment
18
 * @covers Redaxscript\Admin\Controller\ControllerAbstract
19
 */
20
21
class CommentTest extends TestCaseAbstract
22
{
23
	/**
24
	 * setUp
25
	 *
26
	 * @since 4.1.0
27
	 */
28
29
	public function setUp() : void
30
	{
31
		parent::setUp();
32
		$optionArray = $this->getOptionArray();
0 ignored issues
show
The method getOptionArray() does not seem to exist on object<Redaxscript\Tests...Controller\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 = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests...Controller\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...
34
		$installer->init();
35
		$installer->rawCreate();
36
		$installer->insertSettings($optionArray);
37
		Db::forTablePrefix('comments')
38
			->create()
39
			->set(
40
			[
41
				'author' => 'Comment One',
42
				'text' => 'comment-one'
43
			])
44
			->save();
45
	}
46
47
	/**
48
	 * tearDown
49
	 *
50
	 * @since 4.1.0
51
	 */
52
53
	public function tearDown() : void
54
	{
55
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests...Controller\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...
56
	}
57
58
	/**
59
	 * testCreate
60
	 *
61
	 * @since 4.1.0
62
	 *
63
	 * @param array $registryArray
64
	 * @param array $postArray
65
	 * @param string $expect
66
	 *
67
	 * @dataProvider providerAutoloader
68
	 */
69
70
	public function testCreate(array $registryArray = [], array $postArray = [], string $expect = null) : void
71
	{
72
		/* setup */
73
74
		$this->_registry->init($registryArray);
75
		$this->_request->set('post', $postArray);
76
		$commentController = new Admin\Controller\Comment($this->_registry, $this->_request, $this->_language, $this->_config);
77
78
		/* actual */
79
80
		$actual = $commentController->process('create');
81
82
		/* compare */
83
84
		$this->assertEquals($expect, $actual);
85
	}
86
87
	/**
88
	 * testUpdate
89
	 *
90
	 * @since 4.1.0
91
	 *
92
	 * @param array $registryArray
93
	 * @param array $postArray
94
	 * @param string $expect
95
	 *
96
	 * @dataProvider providerAutoloader
97
	 */
98
99
	public function testUpdate(array $registryArray = [], array $postArray = [], string $expect = null) : void
100
	{
101
		/* setup */
102
103
		$this->_registry->init($registryArray);
104
		$this->_request->set('post', $postArray);
105
		$commentController = new Admin\Controller\Comment($this->_registry, $this->_request, $this->_language, $this->_config);
106
107
		/* actual */
108
109
		$actual = $commentController->process('update');
110
111
		/* compare */
112
113
		$this->assertEquals($expect, $actual);
114
	}
115
116
	/**
117
	 * testInvalid
118
	 *
119
	 * @since 4.1.0
120
	 *
121
	 * @param array $registryArray
122
	 * @param array $postArray
123
	 * @param string $expect
124
	 *
125
	 * @dataProvider providerAutoloader
126
	 */
127
128
	public function testInvalid(array $registryArray = [], array $postArray = [], string $expect = null) : void
129
	{
130
		/* setup */
131
132
		$this->_registry->init($registryArray);
133
		$this->_request->set('post', $postArray);
134
		$commentController = new Admin\Controller\Comment($this->_registry, $this->_request, $this->_language, $this->_config);
135
136
		/* actual */
137
138
		$actual = $commentController->process('invalid');
139
140
		/* compare */
141
142
		$this->assertEquals($expect, $actual);
143
	}
144
}
145