1<?php 2 3/** 4 * This file is part of the Phalcon Framework. 5 * 6 * For the full copyright and license information, please view the LICENSE.md 7 * file that was distributed with this source code. 8 */ 9 10declare(strict_types=1); 11 12namespace Phalcon\Test\Unit\Html\Helper\Label; 13 14use Codeception\Example; 15use Phalcon\Escaper; 16use Phalcon\Factory\Exception as ExceptionAlias; 17use Phalcon\Html\Exception; 18use Phalcon\Html\Helper\Label; 19use Phalcon\Html\TagFactory; 20use UnitTester; 21 22class UnderscoreInvokeCest 23{ 24 /** 25 * Tests Phalcon\Html\Helper\Label :: __invoke() 26 * 27 * @param UnitTester $I 28 * @param Example $example 29 * 30 * @throws Exception 31 * @throws ExceptionAlias 32 * @dataProvider getExamples 33 * @since 2020-01-05 34 * 35 */ 36 public function htmlHelperLabelUnderscoreInvoke(UnitTester $I, Example $example) 37 { 38 $I->wantToTest('Html\Helper\Label - __invoke()'); 39 $escaper = new Escaper(); 40 $helper = new Label($escaper); 41 42 $expected = $example[0]; 43 $actual = $helper($example[1]); 44 $I->assertEquals($expected, $actual); 45 46 $factory = new TagFactory($escaper); 47 $locator = $factory->newInstance('label'); 48 $expected = $example[0]; 49 $actual = $locator($example[1]); 50 $I->assertEquals($expected, $actual); 51 } 52 53 /** 54 * @return array 55 */ 56 private function getExamples(): array 57 { 58 return [ 59 [ 60 '<label>', 61 [], 62 ], 63 [ 64 '<label for="my-name" id="my-id">', 65 [ 66 'id' => 'my-id', 67 'for' => 'my-name', 68 ], 69 ], 70 [ 71 '<label for="my-name" id="my-id" class="my-class">', 72 [ 73 'class' => 'my-class', 74 'for' => 'my-name', 75 'id' => 'my-id', 76 ], 77 ], 78 ]; 79 } 80} 81