FormHelperTest.php 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Tools\TestCase\View\Helper;
  3. use Cake\Core\Configure;
  4. use Cake\View\View;
  5. use Tools\TestSuite\TestCase;
  6. use Tools\View\Helper\FormHelper;
  7. /**
  8. * FormHelper tests
  9. */
  10. class FormHelperTest extends TestCase {
  11. /**
  12. * @var \Tools\View\Helper\FormHelper
  13. */
  14. public $Form;
  15. /**
  16. * @return void
  17. */
  18. public function setUp() {
  19. parent::setUp();
  20. Configure::delete('FormConfig');
  21. $this->View = new View(null);
  22. $this->Form = new FormHelper($this->View);
  23. }
  24. /**
  25. * test novalidate for create
  26. *
  27. * @return void
  28. */
  29. public function testCreate() {
  30. $expected = 'novalidate="novalidate"';
  31. $result = $this->Form->create();
  32. $this->assertNotContains($expected, $result);
  33. Configure::write('FormConfig.novalidate', true);
  34. $this->Form = new FormHelper($this->View);
  35. $result = $this->Form->create();
  36. $this->assertContains($expected, $result);
  37. $result = $this->Form->create(null, ['novalidate' => false]);
  38. $this->assertNotContains($expected, $result);
  39. }
  40. }