Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,354 +0,0 @@
1
-<?php declare(strict_types=1);
2
-/**
3
- * Part of Windwalker project Test files.  @codingStandardsIgnoreStart
4
- *
5
- * @copyright  Copyright (C) 2019 LYRASOFT Taiwan, Inc.
6
- * @license    LGPL-2.0-or-later
7
- */
8
-
9
-namespace Windwalker\Renderer\Test;
10
-
11
-use Windwalker\Dom\Test\AbstractDomTestCase;
12
-use Windwalker\Renderer\PhpRenderer;
13
-
14
-/**
15
- * Test class of PhpRenderer
16
- *
17
- * @since 2.0
18
- */
19
-class PhpRendererTest extends AbstractDomTestCase
20
-{
21
-    /**
22
-     * Test instance.
23
-     *
24
-     * @var PhpRenderer
25
-     */
26
-    protected $instance;
27
-
28
-    /**
29
-     * Property path.
30
-     *
31
-     * @var string
32
-     */
33
-    protected static $path;
34
-
35
-    /**
36
-     * Sets up the fixture, for example, opens a network connection.
37
-     * This method is called before a test is executed.
38
-     *
39
-     * @return void
40
-     */
41
-    protected function setUp(): void
42
-    {
43
-        static::$path = realpath(__DIR__ . '/Tmpl/php');
44
-
45
-        if (!static::$path) {
46
-            throw new \RuntimeException('Path not exists');
47
-        }
48
-
49
-        $this->instance = new PhpRenderer(static::$path);
50
-    }
51
-
52
-    /**
53
-     * Tears down the fixture, for example, closes a network connection.
54
-     * This method is called after a test is executed.
55
-     *
56
-     * @return void
57
-     */
58
-    protected function tearDown(): void
59
-    {
60
-    }
61
-
62
-    /**
63
-     * Method to test render().
64
-     *
65
-     * @return void
66
-     *
67
-     * @covers \Windwalker\Renderer\PhpRenderer::render
68
-     */
69
-    public function testRender()
70
-    {
71
-        $html = $this->instance->render('default');
72
-
73
-        $expect = <<<HTML
74
-<div id="default">
75
-    Default
76
-</div>
77
-HTML;
78
-
79
-        $this->assertDomStringEqualsDomString($expect, $html);
80
-    }
81
-
82
-    /**
83
-     * Method to test findFile().
84
-     *
85
-     * @return void
86
-     *
87
-     * @covers \Windwalker\Renderer\PhpRenderer::findFile
88
-     */
89
-    public function testFindFile()
90
-    {
91
-        $file = $this->instance->findFile('flower');
92
-
93
-        $this->assertEquals(realpath(static::$path . '/flower.php'), $file);
94
-
95
-        $file = $this->instance->findFile('foo/bar');
96
-
97
-        $this->assertEquals(realpath(static::$path . '/foo/bar.php'), $file);
98
-    }
99
-
100
-    /**
101
-     * Method to test extend().
102
-     *
103
-     * @return void
104
-     *
105
-     * @covers \Windwalker\Renderer\PhpRenderer::extend
106
-     */
107
-    public function testRenderTopLevelBlock()
108
-    {
109
-        $html = $this->instance->render('extend1');
110
-
111
-        $expect = <<<HTML
112
-<p>
113
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eleifend, ante vitae vestibulum tempus
114
-</p>
115
-HTML;
116
-
117
-        $this->assertDomStringEqualsDomString($expect, $html);
118
-    }
119
-
120
-    /**
121
-     * Method to test extend().
122
-     *
123
-     * @return void
124
-     *
125
-     * @covers \Windwalker\Renderer\PhpRenderer::extend
126
-     */
127
-    public function testExtend()
128
-    {
129
-        $html = $this->instance->render('foo/extend2');
130
-
131
-        $expect = <<<HTML
132
-<p>
133
-Lorem ipsum dolor sit amet,
134
-<span>Vivamus tincidunt consectetur finibus.</span>
135
-Curabitur eleifend, ante vitae vestibulum tempus
136
-</p>
137
-HTML;
138
-
139
-        $this->assertDomStringEqualsDomString($expect, $html);
140
-
141
-        $this->instance->reset();
142
-
143
-        // Render twice
144
-        $html = $this->instance->render('foo/extend3');
145
-
146
-        $expect = <<<HTML
147
-<p>
148
-Lorem ipsum dolor sit amet,
149
-<span>Sed tempor urna quis varius luctus.</span>
150
-Curabitur eleifend, ante vitae vestibulum tempus
151
-</p>
152
-HTML;
153
-
154
-        $this->assertDomStringEqualsDomString($expect, $html);
155
-    }
156
-
157
-    /**
158
-     * testExtendMultiLevels
159
-     *
160
-     * @return  void
161
-     */
162
-    public function testExtendMultiLevels()
163
-    {
164
-        $html = $this->instance->render('foo/extend3');
165
-
166
-        $expect = <<<HTML
167
-<p>
168
-Lorem ipsum dolor sit amet,
169
-<span>Sed tempor urna quis varius luctus.</span>
170
-Curabitur eleifend, ante vitae vestibulum tempus
171
-</p>
172
-HTML;
173
-
174
-        $this->assertDomStringEqualsDomString($expect, $html);
175
-    }
176
-
177
-    /**
178
-     * testExtendWithParent
179
-     *
180
-     * @return  void
181
-     */
182
-    public function testExtendWithParent()
183
-    {
184
-        $html = $this->instance->render('foo/extend-with-parent');
185
-
186
-        $expect = <<<HTML
187
-<p>
188
-Lorem ipsum dolor sit amet,
189
-<span>Vivamus tincidunt consectetur finibus.</span>
190
-<span>Sed tempor urna quis varius luctus.</span>
191
-Curabitur eleifend, ante vitae vestibulum tempus
192
-</p>
193
-HTML;
194
-
195
-        $this->assertDomStringEqualsDomString($expect, $html);
196
-    }
197
-
198
-    /**
199
-     * testLoad
200
-     *
201
-     * @return  void
202
-     */
203
-    public function testLoad()
204
-    {
205
-        $html = $this->instance->render('include1');
206
-
207
-        $expect = <<<HTML
208
-<div id="flower">
209
-    <h1>BAR</h1>
210
-    <p>Quisque egestas posuere enim non dapibus.</p>
211
-</div>
212
-HTML;
213
-
214
-        $this->assertDomStringEqualsDomString($expect, $html);
215
-    }
216
-
217
-    /**
218
-     * testLoadWithData
219
-     *
220
-     * @return  void
221
-     */
222
-    public function testLoadWithData()
223
-    {
224
-        $data = [
225
-            'class' => 'flower',
226
-            'title' => 'Sakura',
227
-            'content' => 'Nulla sollicitudin vel augue quis aliquet.',
228
-        ];
229
-
230
-        $html = $this->instance->render('data1', $data);
231
-
232
-        $expect = <<<HTML
233
-<div id="data" class="flower">
234
-    <h1>Sakura</h1>
235
-    <p>Morbi suscipit ante massa</p>
236
-</div>
237
-HTML;
238
-
239
-        $this->assertDomStringEqualsDomString($expect, $html);
240
-    }
241
-
242
-    /**
243
-     * Method to test escape().
244
-     *
245
-     * @return void
246
-     *
247
-     * @covers \Windwalker\Renderer\AbstractRenderer::escape
248
-     */
249
-    public function testEscape()
250
-    {
251
-        $html = '<div id="data" class="flower" onclick="jQuery(\'#data .gota\').distroy();"></div>';
252
-
253
-        $this->assertEquals(
254
-            '&lt;div id=&quot;data&quot; class=&quot;flower&quot; onclick=&quot;jQuery(\'#data .gota\').distroy();&quot;&gt;&lt;/div&gt;',
255
-            $this->instance->escape($html)
256
-        );
257
-    }
258
-
259
-    /**
260
-     * Method to test getPaths().
261
-     *
262
-     * @return void
263
-     *
264
-     * @covers \Windwalker\Renderer\AbstractRenderer::getPaths
265
-     * @TODO   Implement testGetPaths().
266
-     */
267
-    public function testGetPaths()
268
-    {
269
-        // Remove the following lines when you implement this test.
270
-        $this->markTestIncomplete(
271
-            'This test has not been implemented yet.'
272
-        );
273
-    }
274
-
275
-    /**
276
-     * Method to test setPaths().
277
-     *
278
-     * @return void
279
-     *
280
-     * @covers \Windwalker\Renderer\AbstractRenderer::setPaths
281
-     * @TODO   Implement testSetPaths().
282
-     */
283
-    public function testSetPaths()
284
-    {
285
-        // Remove the following lines when you implement this test.
286
-        $this->markTestIncomplete(
287
-            'This test has not been implemented yet.'
288
-        );
289
-    }
290
-
291
-    /**
292
-     * Method to test addPath().
293
-     *
294
-     * @return void
295
-     *
296
-     * @covers \Windwalker\Renderer\AbstractRenderer::addPath
297
-     * @TODO   Implement testAddPath().
298
-     */
299
-    public function testAddPath()
300
-    {
301
-        // Remove the following lines when you implement this test.
302
-        $this->markTestIncomplete(
303
-            'This test has not been implemented yet.'
304
-        );
305
-    }
306
-
307
-    /**
308
-     * Method to test getBlock().
309
-     *
310
-     * @return void
311
-     *
312
-     * @covers \Windwalker\Renderer\PhpRenderer::getBlock
313
-     * @TODO   Implement testGetBlock().
314
-     */
315
-    public function testGetBlock()
316
-    {
317
-        // Remove the following lines when you implement this test.
318
-        $this->markTestIncomplete(
319
-            'This test has not been implemented yet.'
320
-        );
321
-    }
322
-
323
-    /**
324
-     * Method to test setBlock().
325
-     *
326
-     * @return void
327
-     *
328
-     * @covers \Windwalker\Renderer\PhpRenderer::setBlock
329
-     * @TODO   Implement testSetBlock().
330
-     */
331
-    public function testSetBlock()
332
-    {
333
-        // Remove the following lines when you implement this test.
334
-        $this->markTestIncomplete(
335
-            'This test has not been implemented yet.'
336
-        );
337
-    }
338
-
339
-    /**
340
-     * Method to test getBlockQueue().
341
-     *
342
-     * @return void
343
-     *
344
-     * @covers \Windwalker\Renderer\PhpRenderer::getBlockQueue
345
-     * @TODO   Implement testGetBlockQueue().
346
-     */
347
-    public function testGetBlockQueue()
348
-    {
349
-        // Remove the following lines when you implement this test.
350
-        $this->markTestIncomplete(
351
-            'This test has not been implemented yet.'
352
-        );
353
-    }
354
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,354 @@
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Part of Windwalker project Test files.  @codingStandardsIgnoreStart
4
+ *
5
+ * @copyright  Copyright (C) 2019 LYRASOFT Taiwan, Inc.
6
+ * @license    LGPL-2.0-or-later
7
+ */
8
+
9
+namespace Windwalker\Renderer\Test;
10
+
11
+use Windwalker\Dom\Test\AbstractDomTestCase;
12
+use Windwalker\Renderer\PhpRenderer;
13
+
14
+/**
15
+ * Test class of PhpRenderer
16
+ *
17
+ * @since 2.0
18
+ */
19
+class PhpRendererTest extends AbstractDomTestCase
20
+{
21
+    /**
22
+     * Test instance.
23
+     *
24
+     * @var PhpRenderer
25
+     */
26
+    protected $instance;
27
+
28
+    /**
29
+     * Property path.
30
+     *
31
+     * @var string
32
+     */
33
+    protected static $path;
34
+
35
+    /**
36
+     * Sets up the fixture, for example, opens a network connection.
37
+     * This method is called before a test is executed.
38
+     *
39
+     * @return void
40
+     */
41
+    protected function setUp(): void
42
+    {
43
+        static::$path = realpath(__DIR__ . '/Tmpl/php');
44
+
45
+        if (!static::$path) {
46
+            throw new \RuntimeException('Path not exists');
47
+        }
48
+
49
+        $this->instance = new PhpRenderer(static::$path);
50
+    }
51
+
52
+    /**
53
+     * Tears down the fixture, for example, closes a network connection.
54
+     * This method is called after a test is executed.
55
+     *
56
+     * @return void
57
+     */
58
+    protected function tearDown(): void
59
+    {
60
+    }
61
+
62
+    /**
63
+     * Method to test render().
64
+     *
65
+     * @return void
66
+     *
67
+     * @covers \Windwalker\Renderer\PhpRenderer::render
68
+     */
69
+    public function testRender()
70
+    {
71
+        $html = $this->instance->render('default');
72
+
73
+        $expect = <<<HTML
74
+<div id="default">
75
+    Default
76
+</div>
77
+HTML;
78
+
79
+        $this->assertDomStringEqualsDomString($expect, $html);
80
+    }
81
+
82
+    /**
83
+     * Method to test findFile().
84
+     *
85
+     * @return void
86
+     *
87
+     * @covers \Windwalker\Renderer\PhpRenderer::findFile
88
+     */
89
+    public function testFindFile()
90
+    {
91
+        $file = $this->instance->findFile('flower');
92
+
93
+        $this->assertEquals(realpath(static::$path . '/flower.php'), $file);
94
+
95
+        $file = $this->instance->findFile('foo/bar');
96
+
97
+        $this->assertEquals(realpath(static::$path . '/foo/bar.php'), $file);
98
+    }
99
+
100
+    /**
101
+     * Method to test extend().
102
+     *
103
+     * @return void
104
+     *
105
+     * @covers \Windwalker\Renderer\PhpRenderer::extend
106
+     */
107
+    public function testRenderTopLevelBlock()
108
+    {
109
+        $html = $this->instance->render('extend1');
110
+
111
+        $expect = <<<HTML
112
+<p>
113
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eleifend, ante vitae vestibulum tempus
114
+</p>
115
+HTML;
116
+
117
+        $this->assertDomStringEqualsDomString($expect, $html);
118
+    }
119
+
120
+    /**
121
+     * Method to test extend().
122
+     *
123
+     * @return void
124
+     *
125
+     * @covers \Windwalker\Renderer\PhpRenderer::extend
126
+     */
127
+    public function testExtend()
128
+    {
129
+        $html = $this->instance->render('foo/extend2');
130
+
131
+        $expect = <<<HTML
132
+<p>
133
+Lorem ipsum dolor sit amet,
134
+<span>Vivamus tincidunt consectetur finibus.</span>
135
+Curabitur eleifend, ante vitae vestibulum tempus
136
+</p>
137
+HTML;
138
+
139
+        $this->assertDomStringEqualsDomString($expect, $html);
140
+
141
+        $this->instance->reset();
142
+
143
+        // Render twice
144
+        $html = $this->instance->render('foo/extend3');
145
+
146
+        $expect = <<<HTML
147
+<p>
148
+Lorem ipsum dolor sit amet,
149
+<span>Sed tempor urna quis varius luctus.</span>
150
+Curabitur eleifend, ante vitae vestibulum tempus
151
+</p>
152
+HTML;
153
+
154
+        $this->assertDomStringEqualsDomString($expect, $html);
155
+    }
156
+
157
+    /**
158
+     * testExtendMultiLevels
159
+     *
160
+     * @return  void
161
+     */
162
+    public function testExtendMultiLevels()
163
+    {
164
+        $html = $this->instance->render('foo/extend3');
165
+
166
+        $expect = <<<HTML
167
+<p>
168
+Lorem ipsum dolor sit amet,
169
+<span>Sed tempor urna quis varius luctus.</span>
170
+Curabitur eleifend, ante vitae vestibulum tempus
171
+</p>
172
+HTML;
173
+
174
+        $this->assertDomStringEqualsDomString($expect, $html);
175
+    }
176
+
177
+    /**
178
+     * testExtendWithParent
179
+     *
180
+     * @return  void
181
+     */
182
+    public function testExtendWithParent()
183
+    {
184
+        $html = $this->instance->render('foo/extend-with-parent');
185
+
186
+        $expect = <<<HTML
187
+<p>
188
+Lorem ipsum dolor sit amet,
189
+<span>Vivamus tincidunt consectetur finibus.</span>
190
+<span>Sed tempor urna quis varius luctus.</span>
191
+Curabitur eleifend, ante vitae vestibulum tempus
192
+</p>
193
+HTML;
194
+
195
+        $this->assertDomStringEqualsDomString($expect, $html);
196
+    }
197
+
198
+    /**
199
+     * testLoad
200
+     *
201
+     * @return  void
202
+     */
203
+    public function testLoad()
204
+    {
205
+        $html = $this->instance->render('include1');
206
+
207
+        $expect = <<<HTML
208
+<div id="flower">
209
+    <h1>BAR</h1>
210
+    <p>Quisque egestas posuere enim non dapibus.</p>
211
+</div>
212
+HTML;
213
+
214
+        $this->assertDomStringEqualsDomString($expect, $html);
215
+    }
216
+
217
+    /**
218
+     * testLoadWithData
219
+     *
220
+     * @return  void
221
+     */
222
+    public function testLoadWithData()
223
+    {
224
+        $data = [
225
+            'class' => 'flower',
226
+            'title' => 'Sakura',
227
+            'content' => 'Nulla sollicitudin vel augue quis aliquet.',
228
+        ];
229
+
230
+        $html = $this->instance->render('data1', $data);
231
+
232
+        $expect = <<<HTML
233
+<div id="data" class="flower">
234
+    <h1>Sakura</h1>
235
+    <p>Morbi suscipit ante massa</p>
236
+</div>
237
+HTML;
238
+
239
+        $this->assertDomStringEqualsDomString($expect, $html);
240
+    }
241
+
242
+    /**
243
+     * Method to test escape().
244
+     *
245
+     * @return void
246
+     *
247
+     * @covers \Windwalker\Renderer\AbstractRenderer::escape
248
+     */
249
+    public function testEscape()
250
+    {
251
+        $html = '<div id="data" class="flower" onclick="jQuery(\'#data .gota\').distroy();"></div>';
252
+
253
+        $this->assertEquals(
254
+            '&lt;div id=&quot;data&quot; class=&quot;flower&quot; onclick=&quot;jQuery(\'#data .gota\').distroy();&quot;&gt;&lt;/div&gt;',
255
+            $this->instance->escape($html)
256
+        );
257
+    }
258
+
259
+    /**
260
+     * Method to test getPaths().
261
+     *
262
+     * @return void
263
+     *
264
+     * @covers \Windwalker\Renderer\AbstractRenderer::getPaths
265
+     * @TODO   Implement testGetPaths().
266
+     */
267
+    public function testGetPaths()
268
+    {
269
+        // Remove the following lines when you implement this test.
270
+        $this->markTestIncomplete(
271
+            'This test has not been implemented yet.'
272
+        );
273
+    }
274
+
275
+    /**
276
+     * Method to test setPaths().
277
+     *
278
+     * @return void
279
+     *
280
+     * @covers \Windwalker\Renderer\AbstractRenderer::setPaths
281
+     * @TODO   Implement testSetPaths().
282
+     */
283
+    public function testSetPaths()
284
+    {
285
+        // Remove the following lines when you implement this test.
286
+        $this->markTestIncomplete(
287
+            'This test has not been implemented yet.'
288
+        );
289
+    }
290
+
291
+    /**
292
+     * Method to test addPath().
293
+     *
294
+     * @return void
295
+     *
296
+     * @covers \Windwalker\Renderer\AbstractRenderer::addPath
297
+     * @TODO   Implement testAddPath().
298
+     */
299
+    public function testAddPath()
300
+    {
301
+        // Remove the following lines when you implement this test.
302
+        $this->markTestIncomplete(
303
+            'This test has not been implemented yet.'
304
+        );
305
+    }
306
+
307
+    /**
308
+     * Method to test getBlock().
309
+     *
310
+     * @return void
311
+     *
312
+     * @covers \Windwalker\Renderer\PhpRenderer::getBlock
313
+     * @TODO   Implement testGetBlock().
314
+     */
315
+    public function testGetBlock()
316
+    {
317
+        // Remove the following lines when you implement this test.
318
+        $this->markTestIncomplete(
319
+            'This test has not been implemented yet.'
320
+        );
321
+    }
322
+
323
+    /**
324
+     * Method to test setBlock().
325
+     *
326
+     * @return void
327
+     *
328
+     * @covers \Windwalker\Renderer\PhpRenderer::setBlock
329
+     * @TODO   Implement testSetBlock().
330
+     */
331
+    public function testSetBlock()
332
+    {
333
+        // Remove the following lines when you implement this test.
334
+        $this->markTestIncomplete(
335
+            'This test has not been implemented yet.'
336
+        );
337
+    }
338
+
339
+    /**
340
+     * Method to test getBlockQueue().
341
+     *
342
+     * @return void
343
+     *
344
+     * @covers \Windwalker\Renderer\PhpRenderer::getBlockQueue
345
+     * @TODO   Implement testGetBlockQueue().
346
+     */
347
+    public function testGetBlockQueue()
348
+    {
349
+        // Remove the following lines when you implement this test.
350
+        $this->markTestIncomplete(
351
+            'This test has not been implemented yet.'
352
+        );
353
+    }
354
+}