1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,183 +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\MustacheRenderer; |
|
13 |
- |
|
14 |
-/** |
|
15 |
- * Test class of MustacheRenderer |
|
16 |
- * |
|
17 |
- * @since 2.0 |
|
18 |
- */ |
|
19 |
-class MustacheRendererTest extends AbstractDomTestCase |
|
20 |
-{ |
|
21 |
- /** |
|
22 |
- * Test instance. |
|
23 |
- * |
|
24 |
- * @var MustacheRenderer |
|
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/mustache'); |
|
44 |
- |
|
45 |
- if (!static::$path) { |
|
46 |
- throw new \RuntimeException('Path not exists'); |
|
47 |
- } |
|
48 |
- |
|
49 |
- $this->instance = new MustacheRenderer(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\MustacheRenderer::render |
|
68 |
- */ |
|
69 |
- public function testRender() |
|
70 |
- { |
|
71 |
- $html = $this->instance->render('hello', new Chris()); |
|
72 |
- |
|
73 |
- $expect = <<<HTML |
|
74 |
-Hello Chris |
|
75 |
-You have just won $10000! |
|
76 |
-Well, $6000, after taxes. |
|
77 |
-HTML; |
|
78 |
- |
|
79 |
- $this->assertDomStringEqualsDomString($expect, $html); |
|
80 |
- } |
|
81 |
- |
|
82 |
- /** |
|
83 |
- * Method to test getEngine(). |
|
84 |
- * |
|
85 |
- * @return void |
|
86 |
- * |
|
87 |
- * @covers \Windwalker\Renderer\MustacheRenderer::getEngine |
|
88 |
- * @TODO Implement testGetEngine(). |
|
89 |
- */ |
|
90 |
- public function testGetEngine() |
|
91 |
- { |
|
92 |
- // Remove the following lines when you implement this test. |
|
93 |
- $this->markTestIncomplete( |
|
94 |
- 'This test has not been implemented yet.' |
|
95 |
- ); |
|
96 |
- } |
|
97 |
- |
|
98 |
- /** |
|
99 |
- * Method to test setEngine(). |
|
100 |
- * |
|
101 |
- * @return void |
|
102 |
- * |
|
103 |
- * @covers \Windwalker\Renderer\MustacheRenderer::setEngine |
|
104 |
- * @TODO Implement testSetEngine(). |
|
105 |
- */ |
|
106 |
- public function testSetEngine() |
|
107 |
- { |
|
108 |
- // Remove the following lines when you implement this test. |
|
109 |
- $this->markTestIncomplete( |
|
110 |
- 'This test has not been implemented yet.' |
|
111 |
- ); |
|
112 |
- } |
|
113 |
- |
|
114 |
- /** |
|
115 |
- * Method to test getLoader(). |
|
116 |
- * |
|
117 |
- * @return void |
|
118 |
- * |
|
119 |
- * @covers \Windwalker\Renderer\MustacheRenderer::getLoader |
|
120 |
- * @TODO Implement testGetLoader(). |
|
121 |
- */ |
|
122 |
- public function testGetLoader() |
|
123 |
- { |
|
124 |
- // Remove the following lines when you implement this test. |
|
125 |
- $this->markTestIncomplete( |
|
126 |
- 'This test has not been implemented yet.' |
|
127 |
- ); |
|
128 |
- } |
|
129 |
- |
|
130 |
- /** |
|
131 |
- * Method to test setLoader(). |
|
132 |
- * |
|
133 |
- * @return void |
|
134 |
- * |
|
135 |
- * @covers \Windwalker\Renderer\MustacheRenderer::setLoader |
|
136 |
- * @TODO Implement testSetLoader(). |
|
137 |
- */ |
|
138 |
- public function testSetLoader() |
|
139 |
- { |
|
140 |
- // Remove the following lines when you implement this test. |
|
141 |
- $this->markTestIncomplete( |
|
142 |
- 'This test has not been implemented yet.' |
|
143 |
- ); |
|
144 |
- } |
|
145 |
-} |
|
146 |
-/** |
|
147 |
- * The Chris class. |
|
148 |
- * |
|
149 |
- * @since 2.0 |
|
150 |
- */ |
|
151 |
-class Chris |
|
152 |
-{ |
|
153 |
- /** |
|
154 |
- * Property name. |
|
155 |
- * |
|
156 |
- * @var string |
|
157 |
- */ |
|
158 |
- public $name = "Chris"; |
|
159 |
- |
|
160 |
- /** |
|
161 |
- * Property value. |
|
162 |
- * |
|
163 |
- * @var int |
|
164 |
- */ |
|
165 |
- public $value = 10000; |
|
166 |
- |
|
167 |
- /** |
|
168 |
- * taxed_value |
|
169 |
- * |
|
170 |
- * @return int |
|
171 |
- */ |
|
172 |
- public function taxed_value() |
|
173 |
- { |
|
174 |
- return $this->value - ($this->value * 0.4); |
|
175 |
- } |
|
176 |
- |
|
177 |
- /** |
|
178 |
- * Property in_ca. |
|
179 |
- * |
|
180 |
- * @var bool |
|
181 |
- */ |
|
182 |
- public $in_ca = true; |
|
183 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,183 @@ |
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\MustacheRenderer; |
|
13 |
+ |
|
14 |
+/** |
|
15 |
+ * Test class of MustacheRenderer |
|
16 |
+ * |
|
17 |
+ * @since 2.0 |
|
18 |
+ */ |
|
19 |
+class MustacheRendererTest extends AbstractDomTestCase |
|
20 |
+{ |
|
21 |
+ /** |
|
22 |
+ * Test instance. |
|
23 |
+ * |
|
24 |
+ * @var MustacheRenderer |
|
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/mustache'); |
|
44 |
+ |
|
45 |
+ if (!static::$path) { |
|
46 |
+ throw new \RuntimeException('Path not exists'); |
|
47 |
+ } |
|
48 |
+ |
|
49 |
+ $this->instance = new MustacheRenderer(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\MustacheRenderer::render |
|
68 |
+ */ |
|
69 |
+ public function testRender() |
|
70 |
+ { |
|
71 |
+ $html = $this->instance->render('hello', new Chris()); |
|
72 |
+ |
|
73 |
+ $expect = <<<HTML |
|
74 |
+Hello Chris |
|
75 |
+You have just won $10000! |
|
76 |
+Well, $6000, after taxes. |
|
77 |
+HTML; |
|
78 |
+ |
|
79 |
+ $this->assertDomStringEqualsDomString($expect, $html); |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ /** |
|
83 |
+ * Method to test getEngine(). |
|
84 |
+ * |
|
85 |
+ * @return void |
|
86 |
+ * |
|
87 |
+ * @covers \Windwalker\Renderer\MustacheRenderer::getEngine |
|
88 |
+ * @TODO Implement testGetEngine(). |
|
89 |
+ */ |
|
90 |
+ public function testGetEngine() |
|
91 |
+ { |
|
92 |
+ // Remove the following lines when you implement this test. |
|
93 |
+ $this->markTestIncomplete( |
|
94 |
+ 'This test has not been implemented yet.' |
|
95 |
+ ); |
|
96 |
+ } |
|
97 |
+ |
|
98 |
+ /** |
|
99 |
+ * Method to test setEngine(). |
|
100 |
+ * |
|
101 |
+ * @return void |
|
102 |
+ * |
|
103 |
+ * @covers \Windwalker\Renderer\MustacheRenderer::setEngine |
|
104 |
+ * @TODO Implement testSetEngine(). |
|
105 |
+ */ |
|
106 |
+ public function testSetEngine() |
|
107 |
+ { |
|
108 |
+ // Remove the following lines when you implement this test. |
|
109 |
+ $this->markTestIncomplete( |
|
110 |
+ 'This test has not been implemented yet.' |
|
111 |
+ ); |
|
112 |
+ } |
|
113 |
+ |
|
114 |
+ /** |
|
115 |
+ * Method to test getLoader(). |
|
116 |
+ * |
|
117 |
+ * @return void |
|
118 |
+ * |
|
119 |
+ * @covers \Windwalker\Renderer\MustacheRenderer::getLoader |
|
120 |
+ * @TODO Implement testGetLoader(). |
|
121 |
+ */ |
|
122 |
+ public function testGetLoader() |
|
123 |
+ { |
|
124 |
+ // Remove the following lines when you implement this test. |
|
125 |
+ $this->markTestIncomplete( |
|
126 |
+ 'This test has not been implemented yet.' |
|
127 |
+ ); |
|
128 |
+ } |
|
129 |
+ |
|
130 |
+ /** |
|
131 |
+ * Method to test setLoader(). |
|
132 |
+ * |
|
133 |
+ * @return void |
|
134 |
+ * |
|
135 |
+ * @covers \Windwalker\Renderer\MustacheRenderer::setLoader |
|
136 |
+ * @TODO Implement testSetLoader(). |
|
137 |
+ */ |
|
138 |
+ public function testSetLoader() |
|
139 |
+ { |
|
140 |
+ // Remove the following lines when you implement this test. |
|
141 |
+ $this->markTestIncomplete( |
|
142 |
+ 'This test has not been implemented yet.' |
|
143 |
+ ); |
|
144 |
+ } |
|
145 |
+} |
|
146 |
+/** |
|
147 |
+ * The Chris class. |
|
148 |
+ * |
|
149 |
+ * @since 2.0 |
|
150 |
+ */ |
|
151 |
+class Chris |
|
152 |
+{ |
|
153 |
+ /** |
|
154 |
+ * Property name. |
|
155 |
+ * |
|
156 |
+ * @var string |
|
157 |
+ */ |
|
158 |
+ public $name = "Chris"; |
|
159 |
+ |
|
160 |
+ /** |
|
161 |
+ * Property value. |
|
162 |
+ * |
|
163 |
+ * @var int |
|
164 |
+ */ |
|
165 |
+ public $value = 10000; |
|
166 |
+ |
|
167 |
+ /** |
|
168 |
+ * taxed_value |
|
169 |
+ * |
|
170 |
+ * @return int |
|
171 |
+ */ |
|
172 |
+ public function taxed_value() |
|
173 |
+ { |
|
174 |
+ return $this->value - ($this->value * 0.4); |
|
175 |
+ } |
|
176 |
+ |
|
177 |
+ /** |
|
178 |
+ * Property in_ca. |
|
179 |
+ * |
|
180 |
+ * @var bool |
|
181 |
+ */ |
|
182 |
+ public $in_ca = true; |
|
183 |
+} |