PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/anahkiasen/former/tests/Framework/ZurbFramework4Test.php

https://gitlab.com/hatemdigify/digifyblog
PHP | 142 lines | 107 code | 29 blank | 6 comment | 0 complexity | 191a2d0241d072e031967a85de1ceb5c MD5 | raw file
  1. <?php
  2. namespace Former\Framework;
  3. use Former\TestCases\FormerTests;
  4. class ZurbFramework4Test extends FormerTests
  5. {
  6. public function setUp()
  7. {
  8. parent::setUp();
  9. $this->former->framework('ZurbFoundation4');
  10. $this->former->horizontal_open()->__toString();
  11. }
  12. ////////////////////////////////////////////////////////////////////
  13. ////////////////////////////// MATCHERS ////////////////////////////
  14. ////////////////////////////////////////////////////////////////////
  15. public function matchLabel($name = 'foo', $field = 'foo', $required = false)
  16. {
  17. return array(
  18. 'tag' => 'label',
  19. 'content' => ucfirst($name),
  20. 'attributes' => array(
  21. 'for' => $field,
  22. ),
  23. );
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. //////////////////////////////// TESTS /////////////////////////////
  27. ////////////////////////////////////////////////////////////////////
  28. public function testCanUseMagicMethods()
  29. {
  30. $input = $this->former->large_submit('Save')->__toString();
  31. $matcher = $this->matchInputButton('large button', 'Save');
  32. $this->assertHTML($matcher, $input);
  33. }
  34. public function testCanSetAnErrorStateOnAField()
  35. {
  36. $input = $this->former->text('foo')->state('error')->__toString();
  37. $matcher = array('tag' => 'div', 'attributes' => array('class' => 'error'));
  38. $this->assertLabel($input);
  39. $this->assertHTML($this->matchField(), $input);
  40. $this->assertHTML($matcher, $input);
  41. }
  42. public function testCanAppendHelpTexts()
  43. {
  44. $input = $this->former->text('foo')->inlineHelp('bar')->__toString();
  45. $matcher = array('tag' => 'span', 'content' => 'Bar');
  46. $this->assertLabel($input);
  47. $this->assertHTML($this->matchField(), $input);
  48. $this->assertHTML($matcher, $input);
  49. }
  50. public function testCantUseBootstrapReservedMethods()
  51. {
  52. $this->setExpectedException('BadMethodCallException');
  53. $this->former->text('foo')->blockHelp('bar')->__toString();
  54. }
  55. public function testCreateIconWithFrameworkSpecificIcon()
  56. {
  57. $icon = $this->app['former.framework']->createIcon('smiley')->__toString();
  58. $match = '<i class="general foundicon-smiley"></i>';
  59. $this->assertEquals($match, $icon);
  60. }
  61. public function testCanAppendIcon()
  62. {
  63. $this->former->vertical_open();
  64. $input = $this->former->text('foo')->appendIcon('ok')->__toString();
  65. $match = '<div>'.
  66. '<label for="foo">Foo</label>'.
  67. '<div class="large-10 small-9 columns">'.
  68. '<input id="foo" type="text" name="foo">'.
  69. '</div>'.
  70. '<div class="large-2 small-3 columns">'.
  71. '<span class="postfix">'.
  72. '<i class="general foundicon-ok"></i>'.
  73. '</span>'.
  74. '</div>'.
  75. '</div>';
  76. $this->assertEquals($match, $input);
  77. }
  78. public function testCreateOverideIconSettingsWithFrameworkSpecificIcon()
  79. {
  80. $icon = $this->app['former.framework']->createIcon('smiley')->__toString();
  81. $match = '<i class="general foundicon-smiley"></i>';
  82. $this->assertEquals($match, $icon);
  83. }
  84. public function testVerticalFormInputField()
  85. {
  86. $this->former->vertical_open();
  87. $field = $this->former->text('foo')->__toString();
  88. $match = '<div>'.
  89. '<label for="foo">Foo</label>'.
  90. '<input id="foo" type="text" name="foo">'.
  91. '</div>';
  92. $this->assertEquals($match, $field);
  93. }
  94. public function testHorizontalFormInputField()
  95. {
  96. $field = $this->former->text('foo')->__toString();
  97. $match = '<div class="row">'.
  98. '<div class="small-3 columns">'.
  99. '<label for="foo" class="right inline">Foo</label>'.
  100. '</div>'.
  101. '<div class="small-9 columns">'.
  102. '<input id="foo" type="text" name="foo">'.
  103. '</div>'.
  104. '</div>';
  105. $this->assertEquals($match, $field);
  106. }
  107. public function testHelpTextHasCorrectClasses()
  108. {
  109. $input = $this->former->text('foo')->inlineHelp('bar')->__toString();
  110. $matcher = array('tag' => 'span', 'attributes' => array('class' => 'alert-box radius warning'), 'content' => 'Bar');
  111. $this->assertHTML($matcher, $input);
  112. }
  113. }