Completed
Branch master (7f612f)
by
unknown
09:24
created

ParserTest::testModule()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 15
Code Lines 5

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
namespace Redaxscript\Tests\Content;
3
4
use Redaxscript\Config;
5
use Redaxscript\Language;
6
use Redaxscript\Content;
7
use Redaxscript\Registry;
8
use Redaxscript\Request;
9
use Redaxscript\Tests\TestCaseAbstract;
10
11
/**
12
 * ParserTest
13
 *
14
 * @since 2.1.0
15
 *
16
 * @package Redaxscript
17
 * @category Tests
18
 * @author Henry Ruhs
19
 */
20
21
class ParserTest extends TestCaseAbstract
22
{
23
	/**
24
	 * instance of the registry class
25
	 *
26
	 * @var object
27
	 */
28
29
	protected $_registry;
30
31
	/**
32
	 * instance of the request class
33
	 *
34
	 * @var object
35
	 */
36
37
	protected $_request;
38
39
	/**
40
	 * instance of the language class
41
	 *
42
	 * @var object
43
	 */
44
45
	protected $_language;
46
47
	/**
48
	 * instance of the config class
49
	 *
50
	 * @var object
51
	 */
52
53
	protected $_config;
54
55
	/**
56
	 * setUp
57
	 *
58
	 * @since 2.1.0
59
	 */
60
61
	public function setUp()
62
	{
63
		$this->_registry = Registry::getInstance();
64
		$this->_request = Request::getInstance();
65
		$this->_language = Language::getInstance();
66
		$this->_config = Config::getInstance();
67
	}
68
69
	/**
70
	 * providerBlockcode
71
	 *
72
	 * @since 2.5.0
73
	 *
74
	 * @return array
75
	 */
76
77
	public function providerBlockcode()
78
	{
79
		return $this->getProvider('tests/provider/Content/parser_blockcode.json');
80
	}
81
82
	/**
83
	 * providerLanguage
84
	 *
85
	 * @since 2.5.0
86
	 *
87
	 * @return array
88
	 */
89
90
	public function providerLanguage()
91
	{
92
		return $this->getProvider('tests/provider/Content/parser_language.json');
93
	}
94
95
	/**
96
	 * providerModule
97
	 *
98
	 * @since 2.5.0
99
	 *
100
	 * @return array
101
	 */
102
103
	public function providerModule()
104
	{
105
		return $this->getProvider('tests/provider/Content/parser_module.json');
106
	}
107
108
	/**
109
	 * providerReadmore
110
	 *
111
	 * @since 2.5.0
112
	 *
113
	 * @return array
114
	 */
115
116
	public function providerReadmore()
117
	{
118
		return $this->getProvider('tests/provider/Content/parser_readmore.json');
119
	}
120
121
	/**
122
	 * providerRegistry
123
	 *
124
	 * @since 2.5.0
125
	 *
126
	 * @return array
127
	 */
128
129
	public function providerRegistry()
130
	{
131
		return $this->getProvider('tests/provider/Content/parser_registry.json');
132
	}
133
134
	/**
135
	 * providerTemplate
136
	 *
137
	 * @since 3.0.0
138
	 *
139
	 * @return array
140
	 */
141
142
	public function providerTemplate()
143
	{
144
		return $this->getProvider('tests/provider/Content/parser_template.json');
145
	}
146
147
	/**
148
	 * testBlockcode
149
	 *
150
	 * @since 3.0.0
151
	 *
152
	 * @param string $content
153
	 * @param string $expect
154
	 *
155
	 * @dataProvider providerBlockcode
156
	 */
157
158
	public function testBlockcode($content = null, $expect = null)
159
	{
160
		/* setup */
161
162
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
163
		$parser->process($content);
164
165
		/* actual */
166
167
		$actual = $parser->getOutput();
168
169
		/* compare */
170
171
		$this->assertEquals($expect, $actual);
172
	}
173
174
	/**
175
	 * testLanguage
176
	 *
177
	 * @since 3.0.0
178
	 *
179
	 * @param string $language
180
	 * @param string $content
181
	 * @param string $expect
182
	 *
183
	 * @dataProvider providerLanguage
184
	 */
185
186
	public function testLanguage($language = null, $content = null, $expect = null)
187
	{
188
		/* setup */
189
190
		$this->_language->init($language);
191
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
192
		$parser->process($content);
193
194
		/* actual */
195
196
		$actual = $parser->getOutput();
197
198
		/* compare */
199
200
		$this->assertEquals($expect, $actual);
201
	}
202
203
	/**
204
	 * testModule
205
	 *
206
	 * @since 3.0.0
207
	 *
208
	 * @param string $content
209
	 * @param string $expect
210
	 *
211
	 * @dataProvider providerModule
212
	 */
213
214
	public function testModule($content = null, $expect = null)
215
	{
216
		/* setup */
217
218
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
219
		$parser->process($content);
220
221
		/* actual */
222
223
		$actual = $parser->getOutput();
224
225
		/* compare */
226
227
		$this->assertEquals($expect, $actual);
228
	}
229
230
	/**
231
	 * testReadmore
232
	 *
233
	 * @since 3.0.0
234
	 *
235
	 * @param array $registryArray
236
	 * @param string $content
237
	 * @param string $route
238
	 * @param string $expect
239
	 *
240
	 * @dataProvider providerReadmore
241
	 */
242
243
	public function testReadmore($registryArray = [], $content = null, $route = null, $expect = null)
244
	{
245
		/* setup */
246
247
		$this->_registry->init($registryArray);
248
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
249
		$parser->process($content, $route);
250
251
		/* actual */
252
253
		$actual = $parser->getOutput();
254
255
		/* compare */
256
257
		$this->assertEquals($expect, $actual);
258
	}
259
260
	/**
261
	 * testRegistry
262
	 *
263
	 * @since 3.0.0
264
	 *
265
	 * @param array $registryArray
266
	 * @param string $content
267
	 * @param string $expect
268
	 *
269
	 * @dataProvider providerRegistry
270
	 */
271
272
	public function testRegistry($registryArray = [], $content = null, $expect = null)
273
	{
274
		/* setup */
275
276
		$this->_registry->init($registryArray);
277
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
278
		$parser->process($content);
279
280
		/* actual */
281
282
		$actual = $parser->getOutput();
283
284
		/* compare */
285
286
		$this->assertEquals($expect, $actual);
287
	}
288
289
	/**
290
	 * testTemplate
291
	 *
292
	 * @since 3.0.0
293
	 *
294
	 * @param string $content
295
	 * @param string $expect
296
	 *
297
	 * @dataProvider providerTemplate
298
	 */
299
300
	public function testTemplate($content = null, $expect = null)
301
	{
302
		/* setup */
303
304
		$parser = new Content\Parser($this->_registry, $this->_request, $this->_language, $this->_config);
305
		$parser->process($content);
306
307
		/* actual */
308
309
		$actual = $parser->getOutput();
310
311
		/* compare */
312
313
		$this->assertEquals($expect, $actual);
314
	}
315
}
316