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,208 +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\Test\Stub\StubTwigExtension;
13
-use Windwalker\Renderer\TwigRenderer;
14
-
15
-/**
16
- * Test class of TwigRenderer
17
- *
18
- * @since 2.0
19
- */
20
-class TwigRendererTest extends AbstractDomTestCase
21
-{
22
-    /**
23
-     * Property path.
24
-     *
25
-     * @var string
26
-     */
27
-    protected static $path;
28
-
29
-    /**
30
-     * Test instance.
31
-     *
32
-     * @var TwigRenderer
33
-     */
34
-    protected $instance;
35
-
36
-    /**
37
-     * Sets up the fixture, for example, opens a network connection.
38
-     * This method is called before a test is executed.
39
-     *
40
-     * @return void
41
-     */
42
-    protected function setUp(): void
43
-    {
44
-        static::$path = realpath(__DIR__ . '/Tmpl/twig');
45
-
46
-        if (!static::$path) {
47
-            throw new \RuntimeException('Path not exists');
48
-        }
49
-
50
-        $this->instance = new TwigRenderer(static::$path);
51
-    }
52
-
53
-    /**
54
-     * Tears down the fixture, for example, closes a network connection.
55
-     * This method is called after a test is executed.
56
-     *
57
-     * @return void
58
-     */
59
-    protected function tearDown(): void
60
-    {
61
-    }
62
-
63
-    /**
64
-     * Method to test render().
65
-     *
66
-     * @return void
67
-     *
68
-     * @covers \Windwalker\Renderer\TwigRenderer::render
69
-     */
70
-    public function testRender()
71
-    {
72
-        $html = $this->instance->render('default');
73
-
74
-        $expect = <<<HTML
75
-<div id="global">
76
-    <p> (_global/global) Lorem ipsum dolor sit amet</p>
77
-    <p> (default) Nulla sed libero sem. Praesent ac dignissim risus.</p>
78
-    <p> (foo/bar) Phasellus vitae bibendum neque, quis suscipit urna. Fusce eu odio ante.</p>
79
-    <p> (_global/global) Suspendisse finibus fermentum massa ut tempus. </p>
80
-</div>
81
-HTML;
82
-
83
-        $this->assertDomStringEqualsDomString($expect, $html);
84
-    }
85
-
86
-    /**
87
-     * Method to test render().
88
-     *
89
-     * @return void
90
-     *
91
-     * @covers \Windwalker\Renderer\TwigRenderer::render
92
-     */
93
-    public function testRenderWithDotPath()
94
-    {
95
-        $this->instance->config->set('path_separator', '.');
96
-
97
-        $html = $this->instance->render('default_dot');
98
-
99
-        $expect = <<<HTML
100
-<div id="global">
101
-    <p> (_global/global) Lorem ipsum dolor sit amet</p>
102
-    <p> (default) Nulla sed libero sem. Praesent ac dignissim risus.</p>
103
-    <p> (foo/bar) Phasellus vitae bibendum neque, quis suscipit urna. Fusce eu odio ante.</p>
104
-    <p> (_global/global) Suspendisse finibus fermentum massa ut tempus. </p>
105
-</div>
106
-HTML;
107
-
108
-        $this->assertDomStringEqualsDomString($expect, $html);
109
-    }
110
-
111
-    /**
112
-     * Method to test getLoader().
113
-     *
114
-     * @return void
115
-     *
116
-     * @covers \Windwalker\Renderer\TwigRenderer::getLoader
117
-     */
118
-    public function testGetLoader()
119
-    {
120
-        $this->assertInstanceOf('Twig_Loader_Filesystem', $this->instance->getLoader());
121
-    }
122
-
123
-    /**
124
-     * Method to test setLoader().
125
-     *
126
-     * @return void
127
-     *
128
-     * @covers \Windwalker\Renderer\TwigRenderer::setLoader
129
-     * @TODO   Implement testSetLoader().
130
-     */
131
-    public function testSetLoader()
132
-    {
133
-        // Remove the following lines when you implement this test.
134
-        $this->markTestIncomplete(
135
-            'This test has not been implemented yet.'
136
-        );
137
-    }
138
-
139
-    /**
140
-     * Method to test addExtension().
141
-     *
142
-     * @return void
143
-     *
144
-     * @covers \Windwalker\Renderer\TwigRenderer::addExtension
145
-     */
146
-    public function testAddExtension()
147
-    {
148
-        $this->instance->addExtension(new StubTwigExtension());
149
-
150
-        $html = $this->instance->render('ext-test.twig');
151
-
152
-        $expect = <<<HTML
153
-<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
154
-<p>Suspendisse finibus fermentum massa ut tempus. Sed in pulvinar dolor.</p>
155
-<ul>
156
-    <li>peace</li>
157
-    <li>sakura</li>
158
-    <li>Iron Man</li>
159
-</ul>
160
-HTML;
161
-
162
-        $this->assertDomStringEqualsDomString($expect, $html);
163
-    }
164
-
165
-    /**
166
-     * Method to test setTwig().
167
-     *
168
-     * @return void
169
-     *
170
-     * @covers \Windwalker\Renderer\TwigRenderer::setTwig
171
-     * @TODO   Implement testSetTwig().
172
-     */
173
-    public function testSetTwig()
174
-    {
175
-        // Remove the following lines when you implement this test.
176
-        $this->markTestIncomplete(
177
-            'This test has not been implemented yet.'
178
-        );
179
-    }
180
-
181
-    /**
182
-     * Method to test getDebugExtension().
183
-     *
184
-     * @return void
185
-     *
186
-     * @covers \Windwalker\Renderer\TwigRenderer::getDebugExtension
187
-     */
188
-    public function testGetDebugExtension()
189
-    {
190
-        $this->assertInstanceOf('Twig_Extension_Debug', $this->instance->getDebugExtension());
191
-    }
192
-
193
-    /**
194
-     * Method to test setDebugExtension().
195
-     *
196
-     * @return void
197
-     *
198
-     * @covers \Windwalker\Renderer\TwigRenderer::setDebugExtension
199
-     * @TODO   Implement testSetDebugExtension().
200
-     */
201
-    public function testSetDebugExtension()
202
-    {
203
-        // Remove the following lines when you implement this test.
204
-        $this->markTestIncomplete(
205
-            'This test has not been implemented yet.'
206
-        );
207
-    }
208
-}
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,208 @@
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\Test\Stub\StubTwigExtension;
13
+use Windwalker\Renderer\TwigRenderer;
14
+
15
+/**
16
+ * Test class of TwigRenderer
17
+ *
18
+ * @since 2.0
19
+ */
20
+class TwigRendererTest extends AbstractDomTestCase
21
+{
22
+    /**
23
+     * Property path.
24
+     *
25
+     * @var string
26
+     */
27
+    protected static $path;
28
+
29
+    /**
30
+     * Test instance.
31
+     *
32
+     * @var TwigRenderer
33
+     */
34
+    protected $instance;
35
+
36
+    /**
37
+     * Sets up the fixture, for example, opens a network connection.
38
+     * This method is called before a test is executed.
39
+     *
40
+     * @return void
41
+     */
42
+    protected function setUp(): void
43
+    {
44
+        static::$path = realpath(__DIR__ . '/Tmpl/twig');
45
+
46
+        if (!static::$path) {
47
+            throw new \RuntimeException('Path not exists');
48
+        }
49
+
50
+        $this->instance = new TwigRenderer(static::$path);
51
+    }
52
+
53
+    /**
54
+     * Tears down the fixture, for example, closes a network connection.
55
+     * This method is called after a test is executed.
56
+     *
57
+     * @return void
58
+     */
59
+    protected function tearDown(): void
60
+    {
61
+    }
62
+
63
+    /**
64
+     * Method to test render().
65
+     *
66
+     * @return void
67
+     *
68
+     * @covers \Windwalker\Renderer\TwigRenderer::render
69
+     */
70
+    public function testRender()
71
+    {
72
+        $html = $this->instance->render('default');
73
+
74
+        $expect = <<<HTML
75
+<div id="global">
76
+    <p> (_global/global) Lorem ipsum dolor sit amet</p>
77
+    <p> (default) Nulla sed libero sem. Praesent ac dignissim risus.</p>
78
+    <p> (foo/bar) Phasellus vitae bibendum neque, quis suscipit urna. Fusce eu odio ante.</p>
79
+    <p> (_global/global) Suspendisse finibus fermentum massa ut tempus. </p>
80
+</div>
81
+HTML;
82
+
83
+        $this->assertDomStringEqualsDomString($expect, $html);
84
+    }
85
+
86
+    /**
87
+     * Method to test render().
88
+     *
89
+     * @return void
90
+     *
91
+     * @covers \Windwalker\Renderer\TwigRenderer::render
92
+     */
93
+    public function testRenderWithDotPath()
94
+    {
95
+        $this->instance->config->set('path_separator', '.');
96
+
97
+        $html = $this->instance->render('default_dot');
98
+
99
+        $expect = <<<HTML
100
+<div id="global">
101
+    <p> (_global/global) Lorem ipsum dolor sit amet</p>
102
+    <p> (default) Nulla sed libero sem. Praesent ac dignissim risus.</p>
103
+    <p> (foo/bar) Phasellus vitae bibendum neque, quis suscipit urna. Fusce eu odio ante.</p>
104
+    <p> (_global/global) Suspendisse finibus fermentum massa ut tempus. </p>
105
+</div>
106
+HTML;
107
+
108
+        $this->assertDomStringEqualsDomString($expect, $html);
109
+    }
110
+
111
+    /**
112
+     * Method to test getLoader().
113
+     *
114
+     * @return void
115
+     *
116
+     * @covers \Windwalker\Renderer\TwigRenderer::getLoader
117
+     */
118
+    public function testGetLoader()
119
+    {
120
+        $this->assertInstanceOf('Twig_Loader_Filesystem', $this->instance->getLoader());
121
+    }
122
+
123
+    /**
124
+     * Method to test setLoader().
125
+     *
126
+     * @return void
127
+     *
128
+     * @covers \Windwalker\Renderer\TwigRenderer::setLoader
129
+     * @TODO   Implement testSetLoader().
130
+     */
131
+    public function testSetLoader()
132
+    {
133
+        // Remove the following lines when you implement this test.
134
+        $this->markTestIncomplete(
135
+            'This test has not been implemented yet.'
136
+        );
137
+    }
138
+
139
+    /**
140
+     * Method to test addExtension().
141
+     *
142
+     * @return void
143
+     *
144
+     * @covers \Windwalker\Renderer\TwigRenderer::addExtension
145
+     */
146
+    public function testAddExtension()
147
+    {
148
+        $this->instance->addExtension(new StubTwigExtension());
149
+
150
+        $html = $this->instance->render('ext-test.twig');
151
+
152
+        $expect = <<<HTML
153
+<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
154
+<p>Suspendisse finibus fermentum massa ut tempus. Sed in pulvinar dolor.</p>
155
+<ul>
156
+    <li>peace</li>
157
+    <li>sakura</li>
158
+    <li>Iron Man</li>
159
+</ul>
160
+HTML;
161
+
162
+        $this->assertDomStringEqualsDomString($expect, $html);
163
+    }
164
+
165
+    /**
166
+     * Method to test setTwig().
167
+     *
168
+     * @return void
169
+     *
170
+     * @covers \Windwalker\Renderer\TwigRenderer::setTwig
171
+     * @TODO   Implement testSetTwig().
172
+     */
173
+    public function testSetTwig()
174
+    {
175
+        // Remove the following lines when you implement this test.
176
+        $this->markTestIncomplete(
177
+            'This test has not been implemented yet.'
178
+        );
179
+    }
180
+
181
+    /**
182
+     * Method to test getDebugExtension().
183
+     *
184
+     * @return void
185
+     *
186
+     * @covers \Windwalker\Renderer\TwigRenderer::getDebugExtension
187
+     */
188
+    public function testGetDebugExtension()
189
+    {
190
+        $this->assertInstanceOf('Twig_Extension_Debug', $this->instance->getDebugExtension());
191
+    }
192
+
193
+    /**
194
+     * Method to test setDebugExtension().
195
+     *
196
+     * @return void
197
+     *
198
+     * @covers \Windwalker\Renderer\TwigRenderer::setDebugExtension
199
+     * @TODO   Implement testSetDebugExtension().
200
+     */
201
+    public function testSetDebugExtension()
202
+    {
203
+        // Remove the following lines when you implement this test.
204
+        $this->markTestIncomplete(
205
+            'This test has not been implemented yet.'
206
+        );
207
+    }
208
+}