예제 #1
0
파일: Iframe.php 프로젝트: JBZoo/Html
 /**
  * Create iframe.
  *
  * @param string $src
  * @param string $class
  * @param string $id
  * @param array $attrs
  * @return string
  */
 public function render($src, $class = '', $id = '', array $attrs = array())
 {
     $attrs = array_merge(array('frameborder' => 0, 'content' => null, 'tag' => 'iframe', 'src' => Str::trim($src)), $attrs);
     $attrs = $this->_cleanAttrs($attrs);
     $content = $attrs['content'];
     unset($attrs['content']);
     return Html::_('tag')->render($content, Str::trim($class), Str::trim($id), $attrs);
 }
예제 #2
0
파일: IframeTest.php 프로젝트: JBZoo/Html
 /**
  * Test tag create.
  *
  * @return void
  */
 public function testCreate()
 {
     $Html = Html::getInstance();
     $frame = $Html->_('iframe');
     $actual = $frame->render('http://yandex.ru');
     isSame('<iframe frameborder="0" src="http://yandex.ru"></iframe>', $actual);
     $actual = $frame->render('http://yandex.ru', 'my-class', 'my-id');
     isSame('<iframe frameborder="0" src="http://yandex.ru" id="my-id" class="my-class"></iframe>', $actual);
 }
예제 #3
0
파일: BooleansTest.php 프로젝트: JBZoo/Html
 /**
  * Test bool checkbox.
  *
  * @return void
  */
 public function testCheckbox()
 {
     $radio = Html::_('checkbool');
     $actual = $radio->render('show');
     $expected = array('label' => array('for' => 'preg:/checkbox-[0-9]+/', 'class' => 'jb-checkbox-lbl jb-label-1'), 'input' => array('id' => 'preg:/checkbox-[0-9]+/', 'name' => 'show', 'type' => 'checkbox', 'value' => 1, 'class' => 'jb-val-1'), ' Yes', '/label');
     isHtml($expected, $actual);
     $actual = $radio->render('show', 1, array('data-rel' => 'tooltip'), false);
     $expected = array('input' => array('id' => 'preg:/checkbox-[0-9]+/', 'name' => 'show', 'type' => 'checkbox', 'value' => 1, 'class' => 'jb-val-1', 'data-rel' => 'tooltip', 'checked' => 'checked'), 'label' => array('for' => 'preg:/checkbox-[0-9]+/', 'class' => 'jb-checkbox-lbl jb-label-1'), 'Yes', '/label');
     isHtml($expected, $actual);
 }
예제 #4
0
파일: BoolAbstract.php 프로젝트: JBZoo/Html
 /**
  * Output content.
  *
  * @param string $name
  * @param array $attrs
  * @param int $checked
  * @param bool|true $isLblWrap
  * @return string
  */
 public function render($name, $checked = 0, array $attrs = array(), $isLblWrap = true)
 {
     $this->_type = Str::low($this->_type);
     if ($this->_type === 'radio') {
         $options = array(0 => $this->_translate('No'), 1 => $this->_translate('Yes'));
         return Html::_('radio')->render($options, $name, $checked, $attrs, $isLblWrap);
     } elseif ($this->_type === 'checkbox') {
         $options = array(1 => $this->_translate('Yes'));
         return Html::_('checkbox')->render($options, $name, $checked, $attrs, $isLblWrap);
     }
 }
예제 #5
0
파일: ImageTest.php 프로젝트: JBZoo/Html
 /**
  * Test tag render.
  *
  * @return void
  */
 public function testRender()
 {
     $_SERVER['HTTP_HOST'] = 'host.local';
     $_SERVER['SERVER_PORT'] = 80;
     $Html = Html::getInstance();
     $image = $Html->_('image');
     isSame('<img class="jb-image" src="http://host.local/image.png" />', $image->render('image.png'));
     isSame('<img class="jb-image" src="http://host.local/path/to/image/image.png" />', $image->render('path\\//to\\image/image.png'));
     $actual = $image->render('image.png', 'simple', 'custom', array('class' => array('new-class'), 'id' => 'new-id'));
     isSame('<img class="jb-image simple" id="custom" src="http://host.local/image.png" />', $actual);
     $actual = $image->render('image.png', array('new-class', 'my-image'), 'custom', array('class' => array('new-class'), 'id' => 'new-id'));
     isSame('<img class="jb-image new-class my-image" id="custom" src="http://host.local/image.png" />', $actual);
     $actual = $image->render('image.png', 'my-image', 'custom', array('alt' => 'jb image render', 'fullUrl' => false));
     isSame('<img alt="jb image render" class="jb-image my-image" id="custom" src="image.png" />', $actual);
 }
예제 #6
0
파일: DatalistTest.php 프로젝트: JBZoo/Html
 /**
  * Test tag render.
  *
  * @return void
  */
 public function testRender()
 {
     $_SERVER['HTTP_HOST'] = 'host.local';
     $_SERVER['SERVER_PORT'] = 80;
     $Html = Html::getInstance();
     $list = $Html->_('datalist');
     $data = array('Label 1' => 'Content text 1');
     $actual = $list->render($data);
     $expected = array('dl' => array('class' => 'uk-description-list-horizontal jb-data-list'), array('dt' => array('title')), 'Label 1', '/dt', array('dd' => array()), 'Content text 1', '/dd', '/dl');
     isHtml($expected, $actual);
     isHtmlContain($actual, 'dl > dt', 'Label 1');
     isHtmlContain($actual, 'dl > dd', 'Content text 1');
     $actual = $list->render($data + array('Label 2' => 'Content text 2'), array('class' => 'test', 'id' => 'custom'));
     $expected = array('dl' => array('class' => 'test jb-data-list', 'id' => 'custom'), array('dt' => array('title')), 'Label 1', '/dt', array('dd' => array()), 'Content text 1', '/dd', array('dt' => array('title')), 'Label 2', '/dt', array('dd' => array()), 'Content text 2', '/dd', '/dl');
     isHtml($expected, $actual);
 }
예제 #7
0
파일: HtmlTest.php 프로젝트: JBZoo/Html
 /**
  * Test data attributes.
  *
  * @return void
  */
 public function testDataAttr()
 {
     $Html = Html::getInstance();
     $expected = array('input' => array('data-test' => 'val', 'data-json' => "{'param-1':'val-1','param-2':'val-2'}", 'class' => 'jb-input-text', 'name' => 'test', 'value' => 'val', 'type' => 'text'));
     $input = $Html->_('input')->render('test', 'val', '', '', array('data' => array('test' => 'val', 'json' => array('param-1' => 'val-1', 'param-2' => 'val-2'))));
     isHtml($expected, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $expected = array('input' => array('data-test' => 'val', 'data-json' => "{'param-1':'val-1','param-2':'val-2'}", 'class' => 'jb-input-text', 'name' => 'test', 'value' => 'val', 'type' => 'text'));
     $obj = (object) array('param-1' => 'val-1', 'param-2' => 'val-2');
     $input = $Html->_('input')->render('test', 'val', '', '', array('data' => array('test' => 'val', 'json' => $obj)));
     isHtml($expected, $input);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $expected = array('input' => array('class' => 'jb-input-text', 'name' => 'test', 'value' => 'val', 'type' => 'text'));
     $input = $Html->_('input')->render('test', 'val', '', '', array('data' => array()));
     isHtml($expected, $input);
 }
예제 #8
0
파일: TextAreaTest.php 프로젝트: JBZoo/Html
 /**
  * Test tag render.
  *
  * @return void
  */
 public function testRender()
 {
     $Html = Html::getInstance();
     $textarea = $Html->_('textarea');
     $expected = $textarea->render('test', 'simple content');
     isSame($expected, '<textarea name="test">simple content</textarea>');
     $expected = $textarea->render('test', 'simple content', 'my-class');
     isSame($expected, '<textarea name="test" class="my-class">simple content</textarea>');
     $expected = $textarea->render('test', 'simple content', 'my-class', 'my-id');
     isSame($expected, '<textarea name="test" id="my-id" class="my-class">simple content</textarea>');
     $expected = $textarea->render('test', 'simple content', 'my-class', 'my-id', array('id' => 'new-id', 'class' => 'new-class'));
     isSame($expected, '<textarea id="my-id" name="test" class="my-class">simple content</textarea>');
     $expected = $textarea->render('test', 'simple content', array('my-class', 'array'), 'my-id', array('id' => 'new-id'));
     isSame($expected, '<textarea id="my-id" name="test" class="my-class array">simple content</textarea>');
     $expected = $textarea->render('test', 'simple content', 'my-class', 'my-id', array('title' => 'text title', 'style' => 'color: red;'));
     isSame($expected, '<textarea title="text title" style="color: red;" name="test" id="my-id" class="my-class">simple content</textarea>');
 }
예제 #9
0
파일: ButtonTest.php 프로젝트: JBZoo/Html
 /**
  * Test tag render.
  *
  * @return void
  */
 public function testRender()
 {
     $Html = Html::getInstance();
     $button = $Html->_('button');
     isSame('<button type="submit"></button>', $button->render());
     isSame('<button name="test" type="submit"></button>', $button->render('test'));
     isSame('<button name="test" type="submit"></button>', $button->render('test'));
     $actual = $button->render('test', 'My button');
     isSame('<button name="test" type="submit">My button</button>', $actual);
     $actual = $button->render('test', 'Reset button', array(), 'reset');
     isSame('<button name="test" type="reset">Reset button</button>', $actual);
     $actual = $button->render('test', 'My button', array('button' => 'success'));
     isSame('<button name="test" class="uk-button uk-button-success" type="submit">My button</button>', $actual);
     $actual = $button->render('test', 'My button', array('button' => 'success', 'class' => 'my-class'));
     isSame('<button name="test" class="my-class uk-button uk-button-success" type="submit">My button</button>', $actual);
     $actual = $button->render('test', 'My button', array('button' => 'success', 'icon' => 'stop'));
     $expected = array('button' => array('name' => 'test', 'class' => 'uk-button uk-button-success', 'type' => 'submit'), 'i' => array('class' => 'uk-icon-stop'), '/i', ' My button', '/button');
     isHtml($expected, $actual);
 }
예제 #10
0
 /**
  * Performance render elements.
  *
  * @return void
  */
 public function testRenders()
 {
     $options = $this->_options;
     runBench(array('Select' => function () use($options) {
         return Html::_('select')->render($options, 'default', array('val-29'));
     }, 'Bool' => function () use($options) {
         return Html::_('checkbool')->render('bool');
     }, 'Checkbox' => function () use($options) {
         return Html::_('checkbox')->render($options, 'checkbox', 'val-20');
     }, 'Radio' => function () use($options) {
         return Html::_('radio')->render($options, 'radio', 'val-11');
     }, 'InputText' => function () use($options) {
         return Html::_('input')->render($options, 'input', 'val-11');
     }, 'Textarea' => function () {
         return Html::_('textarea')->render('textarea', 'Text area content');
     }, 'DataList' => function () use($options) {
         return Html::_('datalist')->render($options);
     }), array('count' => 500, 'name' => 'Renders performance'));
 }
예제 #11
0
파일: CheckboxTest.php 프로젝트: JBZoo/Html
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->html = Html::getInstance();
     $this->checkbox = $this->html->_('checkbox');
 }
예제 #12
0
<?php

/**
 * JBZoo Html
 *
 * This file is part of the JBZoo CCK package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   Html
 * @license   MIT
 * @copyright Copyright (C) JBZoo.com,  All rights reserved.
 * @link      https://github.com/JBZoo/Html
 * @author    Sergey Kalistratov <*****@*****.**>
 */
namespace PHPSTORM_META;

/** @noinspection PhpUnusedLocalVariableInspection */
/** @noinspection PhpIllegalArrayKeyTypeInspection */
$STATIC_METHOD_TYPES = [\JBZoo\Html\Html::_('') => ['tag' instanceof \JBZoo\Html\Render\Tag, 'text' instanceof \JBZoo\Html\Render\Text, 'image' instanceof \JBZoo\Html\Render\Image, 'input' instanceof \JBZoo\Html\Render\Input, 'radio' instanceof \JBZoo\Html\Render\Radio, 'hidden' instanceof \JBZoo\Html\Render\Hidden, 'button' instanceof \JBZoo\Html\Render\Button, 'select' instanceof \JBZoo\Html\Render\Select, 'iframe' instanceof \JBZoo\Html\Render\Iframe, 'textarea' instanceof \JBZoo\Html\Render\TextArea, 'datalist' instanceof \JBZoo\Html\Render\Datalist, 'radiobool' instanceof \JBZoo\Html\Render\RadioBool, 'checkbool' instanceof \JBZoo\Html\Render\CheckBool, 'checkbox' instanceof \JBZoo\Html\Render\Checkbox]];
예제 #13
0
파일: TextArea.php 프로젝트: JBZoo/Html
 /**
  * Output content.
  *
  * @param string $name
  * @param string $content
  * @param array|string $class
  * @param string $id
  * @param array $attrs
  * @return string
  */
 public function render($name, $content = '', $class = '', $id = '', array $attrs = array())
 {
     $attrs['name'] = $name;
     $attrs['tag'] = 'textarea';
     return Html::_('tag')->render($content, $class, $id, $attrs);
 }
예제 #14
0
파일: InputTest.php 프로젝트: JBZoo/Html
 /**
  * Test add custom render.
  *
  * @return void
  */
 public function testCustomAddRender()
 {
     $expected = 'Im test custom render';
     $result = $this->html->_('test', 'Custom\\Html')->render('name', 'value', 'class', 'id');
     isSame($expected, $result);
 }
예제 #15
0
파일: RadioTest.php 프로젝트: JBZoo/Html
 /**
  * Test radio list output.
  *
  * return void
  */
 public function testRadio()
 {
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $html = $this->radio->render(array('val-1', 'val-2', 'val-3'), 'test', array(), array(), true);
     $expected = array(array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-0'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 0, 'class' => 'jb-val-0')), ' val-1', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-1'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 1, 'class' => 'jb-val-1')), ' val-2', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-2'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 2, 'class' => 'jb-val-2')), ' val-3', '/label');
     isHtml($expected, $html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Test data and checked single option by array.
     $html = $this->radio->render(array('<p>tag</p>' => 'Tag', ' ' => 'Empty', '"Test label 3"' => 'Custom', 'значение' => 'Translate cyrillic value', 'common' => 'Common label'), 'test', array('common'), array(), true);
     $expected = array(array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-lt-p-gt-tag-lt-p-gt'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => '&lt;p&gt;tag&lt;/p&gt;', 'class' => 'jb-val-lt-p-gt-tag-lt-p-gt')), ' Tag', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => ' ', 'class' => 'jb-val-')), ' Empty', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-quot-test-label-3-quot'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => '&quot;Test label 3&quot;', 'class' => 'jb-val-quot-test-label-3-quot')), ' Custom', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-znachenie'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'значение', 'class' => 'jb-val-znachenie')), ' Translate cyrillic value', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-common'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'common', 'class' => 'jb-val-common', 'checked' => 'checked')), ' Common label', '/label');
     isHtml($expected, $html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Test checked single option by string.
     $html = $this->radio->render(array('"Test label 3"' => 'Custom', 'значение' => 'Translate cyrillic value', 'common' => 'Common label'), 'test', 'common', array(), true);
     $expected = array(array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-quot-test-label-3-quot'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => '&quot;Test label 3&quot;', 'class' => 'jb-val-quot-test-label-3-quot')), ' Custom', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-znachenie'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'значение', 'class' => 'jb-val-znachenie')), ' Translate cyrillic value', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-common'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'common', 'class' => 'jb-val-common', 'checked' => 'checked')), ' Common label', '/label');
     isHtml($expected, $html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $html = $this->radio->render(array('test-7' => 'Test label 7', 'test-8' => 'Test label 8'), 'test', array('common', 'test-8', 'test-2', 'test-4'));
     $expected = array(array('input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'no-exits', 'class' => 'jb-val-no-exits', 'checked' => 'checked')), array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-no-exits')), 'No exits', '/label', array('input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-7', 'class' => 'jb-val-test-7')), array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-7')), 'Test label 7', '/label', array('input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-8', 'class' => 'jb-val-test-8')), array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-8')), 'Test label 8', '/label');
     isHtml($expected, $html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $html = $this->radio->render(array('test-7' => 'Test label 7', 'test-8' => 'Test label 8'), 'test', 'test');
     $expected = array(array('input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'no-exits', 'class' => 'jb-val-no-exits', 'checked' => 'checked')), array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-no-exits')), 'No exits', '/label', array('input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-7', 'class' => 'jb-val-test-7')), array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-7')), 'Test label 7', '/label', array('input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-8', 'class' => 'jb-val-test-8')), array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-8')), 'Test label 8', '/label');
     isHtml($expected, $html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Test checked options by array.
     $html = $this->radio->render(array('test-1' => 'Test label 1', 'test-2' => 'Test label 2', 'test-3' => 'Test label 3', 'test-4' => 'Test label 4', 'test-6' => 'Test label 6', 'test-7' => 'Test label 7', 'test-8' => 'Test label 8', 'common' => 'Common label'), 'test', array('common', 'test-8', 'test-2', 'test-4'), array(), true);
     $expected = array(array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-1'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-1', 'class' => 'jb-val-test-1')), ' Test label 1', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-2'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-2', 'class' => 'jb-val-test-2')), ' Test label 2', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-3'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-3', 'class' => 'jb-val-test-3')), ' Test label 3', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-4'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-4', 'class' => 'jb-val-test-4', 'checked' => 'checked')), ' Test label 4', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-6'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-6', 'class' => 'jb-val-test-6')), ' Test label 6', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-7'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-7', 'class' => 'jb-val-test-7')), ' Test label 7', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-8'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-8', 'class' => 'jb-val-test-8')), ' Test label 8', '/label', array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-common'), 'input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'common', 'class' => 'jb-val-common')), ' Common label', '/label');
     isHtml($expected, $html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Test setup callable template.
     $options = array('test-1' => 'Test label 1');
     $html = $this->radio->render($options, 'test', 0, array(), function ($list, $name, $value, $id, $text, $attrs) {
         $alias = Str::slug($value, true);
         $inpClass = 'jb-val-' . $alias;
         $input = $list->input($name, $value, $id, $inpClass, $attrs);
         $text = '<span class="label-title">' . $text . '</span>';
         $label = $list->label($id, $alias, $text);
         return implode(PHP_EOL, array($input, $label));
     });
     $expected = array(array('input' => array('id' => 'preg:/radio-[0-9]+/', 'name' => 'test', 'type' => 'radio', 'value' => 'test-1', 'class' => 'jb-val-test-1', 'checked' => 'checked')), array('label' => array('for' => 'preg:/radio-[0-9]+/', 'class' => 'jb-radio-lbl jb-label-test-1')), 'span' => array('class' => 'label-title'), 'Test label 1', '/span', '/label');
     isHtml($expected, $html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $html = $this->radio->render($options, 'test', 0, array(), 'no-exits');
     isEmpty($html);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $inputReload = Html::_('checkbox', 'Custom\\Html');
     $html = $inputReload->render($options, 'test');
     $expected = array('div' => array('class' => 'jb-input jb-checkbox'), 'label' => array('for' => 'preg:/checkbox-[0-9]+/', 'class' => 'jb-checkbox-lbl jb-label-test-1'), array('input' => array('id' => 'preg:/checkbox-[0-9]+/', 'name' => 'test', 'type' => 'checkbox', 'value' => 'test-1', 'class' => 'jb-val-test-1')), 'span' => array('class' => 'label-title'), 'Test label 1', '/span', '/label', '/div');
     isHtml($expected, $html);
 }
예제 #16
0
파일: SelectTest.php 프로젝트: JBZoo/Html
 /**     * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->html = Html::getInstance();
     $this->select = $this->html->_('select');
 }
예제 #17
0
파일: HiddenTest.php 프로젝트: JBZoo/Html
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->html = Html::getInstance();
     $this->hidden = $this->html->_('hidden');
 }