Last active
December 20, 2015 08:59
-
-
Save crisu83/6104549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Codeception\Util\Stub; | |
Yii::import('bootstrap.helpers.TbHtml'); | |
Yii::import('bootstrap.tests.unit.Dummy'); | |
class TbHtmlTest extends \Codeception\TestCase\Test | |
{ | |
/** | |
* @var \CodeGuy | |
*/ | |
protected $codeGuy; | |
protected function _before() | |
{ | |
} | |
protected function _after() | |
{ | |
} | |
public function testLead() | |
{ | |
$html = TbHtml::lead('Lead text'); | |
$p = $this->codeGuy->createNode($html, 'p.lead'); | |
$this->codeGuy->seeNodeText($p, 'Lead text'); | |
} | |
public function testSmall() | |
{ | |
$html = TbHtml::small('Small text'); | |
$small = $this->codeGuy->createNode($html, 'small'); | |
$this->codeGuy->seeNodeText($small, 'Small text'); | |
} | |
public function testBold() | |
{ | |
$html = TbHtml::b('Bold text'); | |
$strong = $this->codeGuy->createNode($html, 'strong'); | |
$this->codeGuy->seeNodeText($strong, 'Bold text'); | |
} | |
public function testItalic() | |
{ | |
$html = TbHtml::i('Italic text'); | |
$em = $this->codeGuy->createNode($html, 'em'); | |
$this->codeGuy->seeNodeText($em, 'Italic text'); | |
} | |
public function testEmphasize() | |
{ | |
$html = TbHtml::em('Warning text', array('color' => TbHtml::TEXT_COLOR_WARNING)); | |
$span = $this->codeGuy->createNode($html, 'p.text-warning'); | |
$this->codeGuy->seeNodeText($span, 'Warning text'); | |
$html = TbHtml::em('Success text', array('color' => TbHtml::TEXT_COLOR_SUCCESS), 'span'); | |
$span = $this->codeGuy->createNode($html, 'span.text-success'); | |
$this->codeGuy->seeNodeText($span, 'Success text'); | |
} | |
public function testMuted() | |
{ | |
$html = TbHtml::muted('Muted text'); | |
$p = $this->codeGuy->createNode($html, 'p.muted'); | |
$this->codeGuy->seeNodeText($p, 'Muted text'); | |
} | |
public function testMutedSpan() | |
{ | |
$html = TbHtml::mutedSpan('Muted text'); | |
$span = $this->codeGuy->createNode($html, 'span.muted'); | |
$this->codeGuy->seeNodeText($span, 'Muted text'); | |
} | |
public function testAbbreviation() | |
{ | |
$html = TbHtml::abbr('Abbreviation', 'Word'); | |
$abbr = $this->codeGuy->createNode($html, 'abbr'); | |
$this->codeGuy->seeNodeAttribute($abbr, 'title', 'Word'); | |
$this->codeGuy->seeNodeText($abbr, 'Abbreviation'); | |
} | |
public function testSmallAbbreviation() | |
{ | |
$html = TbHtml::smallAbbr('Abbreviation', 'Word'); | |
$abbr = $this->codeGuy->createNode($html, 'abbr'); | |
$this->codeGuy->seeNodeAttribute($abbr, 'title', 'Word'); | |
$this->codeGuy->seeNodeCssClass($abbr,'initialism'); | |
$this->codeGuy->seeNodeText($abbr, 'Abbreviation'); | |
} | |
public function testAddress() | |
{ | |
$html = TbHtml::address('Address text'); | |
$addr = $this->codeGuy->createNode($html, 'address'); | |
$this->codeGuy->seeNodeText($addr, 'Address text'); | |
} | |
public function testQuote() | |
{ | |
$html = TbHtml::quote('Quote text', array( | |
'paragraphOptions' => array('class' => 'paragraph'), | |
'source' => 'Source text', | |
'sourceOptions' => array('class' => 'source'), | |
'cite' => 'Cited text', | |
'citeOptions' => array('class' => 'cite'), | |
)); | |
$blockquote = $this->codeGuy->createNode($html, 'blockquote'); | |
$this->codeGuy->seeNodeChildren($blockquote, array('p', 'small')); | |
$p = $blockquote->filter('p'); | |
$this->codeGuy->seeNodeCssClass($p, 'paragraph'); | |
$this->codeGuy->seeNodeText($p, 'Quote text'); | |
$small = $blockquote->filter('small'); | |
$this->codeGuy->seeNodeCssClass($small, 'source'); | |
$this->codeGuy->seeNodeText($small, 'Source text'); | |
$cite = $small->filter('cite'); | |
$this->codeGuy->seeNodeCssClass($cite, 'cite'); | |
$this->codeGuy->seeNodeText($cite, 'Cited text'); | |
} | |
public function testHelp() | |
{ | |
$html = TbHtml::help('Help text'); | |
$span = $this->codeGuy->createNode($html, 'span'); | |
$this->codeGuy->seeNodeCssClass($span, 'help-inline'); | |
$this->codeGuy->seeNodeText($span, 'Help text'); | |
} | |
public function testHelpBlock() | |
{ | |
$html = TbHtml::helpBlock('Help text'); | |
$p = $this->codeGuy->createNode($html, 'p'); | |
$this->codeGuy->seeNodeCssClass($p, 'help-block'); | |
$this->codeGuy->seeNodeText($p, 'Help text'); | |
} | |
public function testCode() | |
{ | |
$html = TbHtml::code('Source code'); | |
$code = $this->codeGuy->createNode($html, 'code'); | |
$this->codeGuy->seeNodeText($code, 'Source code'); | |
} | |
public function testCodeBlock() | |
{ | |
$html = TbHtml::codeBlock('Source code'); | |
$pre = $this->codeGuy->createNode($html, 'pre'); | |
$this->codeGuy->seeNodeText($pre, 'Source code'); | |
} | |
public function testTag() | |
{ | |
$html = TbHtml::tag('div', array( | |
'textAlign' => TbHtml::TEXT_ALIGN_RIGHT, | |
'pull' => TbHtml::PULL_RIGHT, | |
'span' => 3, | |
), 'Content'); | |
$div = $this->codeGuy->createNode($html, 'div'); | |
$this->codeGuy->seeNodeCssClass($div, 'pull-right span3 text-right'); | |
} | |
public function testOpenTag() | |
{ | |
$html = TbHtml::openTag('p', array( | |
'class' => 'tag', | |
)); | |
$p = $this->codeGuy->createNode($html, 'p'); | |
$this->codeGuy->seeNodeCssClass($p, 'tag'); | |
} | |
public function testForm() | |
{ | |
$html = TbHtml::beginFormTb(TbHtml::FORM_LAYOUT_VERTICAL, '#'); | |
$form = $this->codeGuy->createNode($html, 'form'); | |
$this->codeGuy->seeNodeCssClass($form, 'form-vertical'); | |
$this->codeGuy->seeNodeAttributes($form, array( | |
'action' => '#', | |
'method' => 'post' | |
)); | |
} | |
public function testTextField() | |
{ | |
$html = TbHtml::textField('text', 'text', array( | |
'class' => 'text', | |
)); | |
$input = $this->codeGuy->createNode($html, 'input'); | |
$this->codeGuy->seeNodeCssClass($input, 'text'); | |
$this->codeGuy->seeNodeAttributes($input, array( | |
'type' => 'text', | |
'id' => 'text', | |
'name' => 'text', | |
'value' => 'text', | |
)); | |
$html = TbHtml::textField('text', 'text', array( | |
'prepend' => 'Prepend text', | |
)); | |
$div = $this->codeGuy->createNode($html, 'div'); | |
$this->codeGuy->seeNodeCssClass($div, 'input-prepend'); | |
$this->codeGuy->seeNodeChildren($div, array('span', 'input')); | |
$span = $div->filter('span.add-on'); | |
$this->codeGuy->seeNodeText($span, 'Prepend text'); | |
$html = TbHtml::textField('text', 'text', array( | |
'append' => 'Append text', | |
)); | |
$div = $this->codeGuy->createNode($html, 'div'); | |
$this->codeGuy->seeNodeCssClass($div, 'input-append'); | |
$this->codeGuy->seeNodeChildren($div, array('input', 'span')); | |
$span = $div->filter('span.add-on'); | |
$this->codeGuy->seeNodeText($span, 'Append text'); | |
$html = TbHtml::textField('text', 'text', array( | |
'prepend' => 'Prepend text', | |
'append' => 'Append text', | |
)); | |
$div = $this->codeGuy->createNode($html, 'div'); | |
$this->codeGuy->seeNodeCssClass($div, 'input-prepend input-append'); | |
$this->codeGuy->seeNodeChildren($div, array('span', 'input', 'span')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment