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

tests/unit/Content/ParserTest.php (4 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\Content;
3
4
use Redaxscript\Content;
5
use Redaxscript\Module;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * ParserTest
10
 *
11
 * @since 2.1.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Content\Parser
18
 * @covers Redaxscript\Content\ParserAbstract
19
 * @covers Redaxscript\Content\Tag\Code
20
 * @covers Redaxscript\Content\Tag\Language
21
 * @covers Redaxscript\Content\Tag\Module
22
 * @covers Redaxscript\Content\Tag\More
23
 * @covers Redaxscript\Content\Tag\Registry
24
 * @covers Redaxscript\Content\Tag\TagAbstract
25
 * @covers Redaxscript\Content\Tag\Template
26
 */
27
28
class ParserTest extends TestCaseAbstract
29
{
30
	/**
31
	 * setUp
32
	 *
33
	 * @since 3.1.0
34
	 */
35
36
	public function setUp() : void
37
	{
38
		parent::setUp();
39
		$optionArray =
40
		[
41
			'adminName' => 'Test',
42
			'adminUser' => 'test',
43
			'adminPassword' => 'test',
44
			'adminEmail' => '[email protected]'
45
		];
46
		$installer = $this->installerFactory();
0 ignored issues
show
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\Content\ParserTest>.

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...
47
		$installer->init();
48
		$installer->rawCreate();
49
		$installer->insertSettings($optionArray);
50
		$this->installTestDummy();
0 ignored issues
show
The method installTestDummy() does not seem to exist on object<Redaxscript\Tests\Content\ParserTest>.

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...
51
	}
52
53
	/**
54
	 * tearDown
55
	 *
56
	 * @since 3.1.0
57
	 */
58
59
	public function tearDown() : void
60
	{
61
		$this->uninstallTestDummy();
0 ignored issues
show
The method uninstallTestDummy() does not seem to exist on object<Redaxscript\Tests\Content\ParserTest>.

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...
62
		$this->dropDatabase();
0 ignored issues
show
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\Content\ParserTest>.

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...
63
	}
64
65
	/**
66
	 * testCode
67
	 *
68
	 * @since 3.0.0
69
	 *
70
	 * @param string $content
71
	 * @param string $expect
72
	 *
73
	 * @dataProvider providerAutoloader
74
	 */
75
76
	public function testCode(string $content = null, string $expect = null) : void
77
	{
78
		/* setup */
79
80
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
81
		$parser->process($content);
82
83
		/* actual */
84
85
		$actual = $parser->getOutput();
86
87
		/* compare */
88
89
		$this->assertEquals($expect, $actual);
90
	}
91
92
	/**
93
	 * testLanguage
94
	 *
95
	 * @since 3.0.0
96
	 *
97
	 * @param string $language
98
	 * @param string $content
99
	 * @param string $expect
100
	 *
101
	 * @dataProvider providerAutoloader
102
	 */
103
104
	public function testLanguage(string $language = null, string $content = null, string $expect = null) : void
105
	{
106
		/* setup */
107
108
		$this->_language->init($language);
109
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
110
		$parser->process($content);
111
112
		/* actual */
113
114
		$actual = $parser->getOutput();
115
116
		/* compare */
117
118
		$this->assertEquals($expect, $actual);
119
	}
120
121
	/**
122
	 * testModule
123
	 *
124
	 * @since 3.0.0
125
	 *
126
	 * @param string $content
127
	 * @param string $expect
128
	 *
129
	 * @dataProvider providerAutoloader
130
	 */
131
132
	public function testModule(string $content = null, string $expect = null) : void
133
	{
134
		/* setup */
135
136
		Module\Hook::construct($this->_registry, $this->_request, $this->_language, $this->_config);
137
		Module\Hook::init();
138
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
139
		$parser->process($content);
140
141
		/* actual */
142
143
		$actual = $parser->getOutput();
144
145
		/* compare */
146
147
		$this->assertEquals($expect, $actual);
148
	}
149
150
	/**
151
	 * testMore
152
	 *
153
	 * @since 3.0.0
154
	 *
155
	 * @param array $registryArray
156
	 * @param string $content
157
	 * @param string $route
158
	 * @param string $expect
159
	 *
160
	 * @dataProvider providerAutoloader
161
	 */
162
163
	public function testMore(array $registryArray = [], string $content = null, string $route = null, string $expect = null) : void
164
	{
165
		/* setup */
166
167
		$this->_registry->init($registryArray);
168
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
169
		$parser->process($content, $route);
170
171
		/* actual */
172
173
		$actual = $parser->getOutput();
174
175
		/* compare */
176
177
		$this->assertEquals($expect, $actual);
178
	}
179
180
	/**
181
	 * testRegistry
182
	 *
183
	 * @since 3.0.0
184
	 *
185
	 * @param array $registryArray
186
	 * @param string $content
187
	 * @param string $expect
188
	 *
189
	 * @dataProvider providerAutoloader
190
	 */
191
192
	public function testRegistry(array $registryArray = [], string $content = null, string $expect = null) : void
193
	{
194
		/* setup */
195
196
		$this->_registry->init($registryArray);
197
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
198
		$parser->process($content);
199
200
		/* actual */
201
202
		$actual = $parser->getOutput();
203
204
		/* compare */
205
206
		$this->assertEquals($expect, $actual);
207
	}
208
209
	/**
210
	 * testTemplate
211
	 *
212
	 * @since 3.0.0
213
	 *
214
	 * @param string $content
215
	 * @param string $expect
216
	 *
217
	 * @dataProvider providerAutoloader
218
	 */
219
220
	public function testTemplate(string $content = null, string $expect = null) : void
221
	{
222
		/* setup */
223
224
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
225
		$parser->process($content);
226
227
		/* actual */
228
229
		$actual = $parser->getOutput();
230
231
		/* compare */
232
233
		$this->assertEquals($expect, $actual);
234
	}
235
}
236