1 | <?php |
||
21 | class HtmlElementTest extends TestCase |
||
22 | { |
||
23 | /** |
||
24 | * PHP errors |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $errors = array(); |
||
29 | |||
30 | /** |
||
31 | * Test error handler to get php errors |
||
32 | * |
||
33 | * @param int $errno |
||
34 | * @param string $errstr |
||
35 | * @param string $errfile |
||
36 | * @param string $errline |
||
37 | * @param string $errcontext |
||
38 | */ |
||
39 | public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) |
||
43 | |||
44 | /** |
||
45 | * Checks if php error was occured |
||
46 | * |
||
47 | * @param int $errno |
||
48 | * @param string $errstr |
||
49 | * @return bool True if exists, otherwise false |
||
50 | */ |
||
51 | public function hasError($errno, $errstr) |
||
61 | |||
62 | /** |
||
63 | * Tests setTag |
||
64 | * |
||
65 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setTag |
||
66 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::getTag |
||
67 | * @group view |
||
68 | */ |
||
69 | public function testSetTag() |
||
78 | |||
79 | /** |
||
80 | * Tests setId |
||
81 | * |
||
82 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setId |
||
83 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::getId |
||
84 | * @group view |
||
85 | */ |
||
86 | public function testSetId() |
||
95 | |||
96 | /** |
||
97 | * Tests setClass |
||
98 | * |
||
99 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setClass |
||
100 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::getClass |
||
101 | * @group view |
||
102 | */ |
||
103 | public function testSetClass() |
||
112 | |||
113 | /** |
||
114 | * Tests appendClass |
||
115 | * |
||
116 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::appendClass |
||
117 | * @depends testSetClass |
||
118 | * @group view |
||
119 | */ |
||
120 | public function testAppendClass() |
||
134 | |||
135 | /** |
||
136 | * Tests setText |
||
137 | * |
||
138 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setText |
||
139 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::getText |
||
140 | * @group view |
||
141 | */ |
||
142 | public function testSetText() |
||
151 | |||
152 | /** |
||
153 | * Tests appendText |
||
154 | * |
||
155 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::appendText |
||
156 | * @depends testSetText |
||
157 | * @group view |
||
158 | */ |
||
159 | public function testAppendText() |
||
173 | |||
174 | /** |
||
175 | * Tests setAttributes |
||
176 | * |
||
177 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setAttributes |
||
178 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::getAttributes |
||
179 | * @group view |
||
180 | */ |
||
181 | public function testSetAttributes() |
||
201 | |||
202 | /** |
||
203 | * Tests if html rendering can be enabled / disabled |
||
204 | * |
||
205 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::enableHtml |
||
206 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::useHtml |
||
207 | * @group view |
||
208 | */ |
||
209 | public function testToggleHtmlRendering() |
||
221 | |||
222 | /** |
||
223 | * Tests setEscapeText |
||
224 | * |
||
225 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setEscapeText |
||
226 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::isEscapeText |
||
227 | * @group view |
||
228 | */ |
||
229 | public function testSetEscapeText() |
||
240 | |||
241 | /** |
||
242 | * Tests setEscapeHtmlAttributes |
||
243 | * |
||
244 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setEscapeHtmlAttribute |
||
245 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::isEscapeHtmlAttribute |
||
246 | * @group view |
||
247 | */ |
||
248 | public function testSetEscapeHtmlAttributes() |
||
259 | |||
260 | |||
261 | /** |
||
262 | * Tests setEscaper |
||
263 | * |
||
264 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::setEscaper |
||
265 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::getEscaper |
||
266 | * @group view |
||
267 | */ |
||
268 | public function testSetEscaper() |
||
279 | |||
280 | /** |
||
281 | * Tests if call of view helper return new html element object with specified objects |
||
282 | * |
||
283 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::__invoke |
||
284 | * @depends testSetText |
||
285 | * @depends testSetClass |
||
286 | * @depends testToggleHtmlRendering |
||
287 | * @group view |
||
288 | */ |
||
289 | public function testInvokeShouldReturnObjectWithSpecifiedOptions() |
||
309 | |||
310 | /** |
||
311 | * Tests if html element rendered successfully |
||
312 | * |
||
313 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::render |
||
314 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::buildAttributes |
||
315 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::__toString |
||
316 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::toString |
||
317 | * @depends testInvokeShouldReturnObjectWithSpecifiedOptions |
||
318 | * @group view |
||
319 | */ |
||
320 | public function testToStringShouldTriggerErrorIfExceptionOccurs() |
||
361 | |||
362 | /** |
||
363 | * Tests if html element rendered successfully |
||
364 | * |
||
365 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::render |
||
366 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::buildAttributes |
||
367 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::__toString |
||
368 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::toString |
||
369 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::escapeHtmlAttribute |
||
370 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::escapeText |
||
371 | * @depends testInvokeShouldReturnObjectWithSpecifiedOptions |
||
372 | * @group view |
||
373 | */ |
||
374 | public function testRender() |
||
400 | |||
401 | /** |
||
402 | * Tests if html element rendered self closing tag successfully |
||
403 | * |
||
404 | * @depends testInvokeShouldReturnObjectWithSpecifiedOptions |
||
405 | * @dataProvider dataProviderForTestRenderWithSelfClosingTag |
||
406 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::render |
||
407 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::buildAttributes |
||
408 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::__toString |
||
409 | * @covers \Sake\HtmlElement\View\Helper\HtmlElement::toString |
||
410 | * @group view |
||
411 | */ |
||
412 | public function testRenderWithSelfClosingTag($tag) |
||
431 | |||
432 | /** |
||
433 | * Returns stub with mocked view plugin manager |
||
434 | * |
||
435 | * @return \PHPUnit_Framework_MockObject_MockObject |
||
436 | */ |
||
437 | protected function getStubWithEscaper(array $methods = array()) |
||
460 | |||
461 | /** |
||
462 | * data provider for the test method testRenderWithSelfClosingTag() |
||
463 | * |
||
464 | * @return array |
||
465 | */ |
||
466 | public function dataProviderForTestRenderWithSelfClosingTag() |
||
519 | |||
520 | private function getMock($class, $methods) |
||
526 | } |
||
527 |