Esempio n. 1
0
 /**
  * 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);
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * 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);
 }
Esempio n. 4
0
 /**
  * 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);
 }
Esempio n. 5
0
 /**
  * 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>');
 }
Esempio n. 6
0
 /**
  * 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);
 }
Esempio n. 7
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->html = Html::getInstance();
     $this->checkbox = $this->html->_('checkbox');
 }
Esempio n. 8
0
 /**     * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->html = Html::getInstance();
     $this->select = $this->html->_('select');
 }
Esempio n. 9
0
 /**
  * Test default renders.
  *
  * @return void.
  */
 public function testDefaultInstance()
 {
     $Html = Html::getInstance();
     isClass('JBZoo\\Html\\Render\\Input', $Html->_('Input'));
     isClass('JBZoo\\Html\\Render\\Input', $Html->_('input'));
 }
Esempio n. 10
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->html = Html::getInstance();
     $this->radio = $this->html->_('radio');
 }
Esempio n. 11
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->html = Html::getInstance();
     $this->hidden = $this->html->_('hidden');
 }