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