FormHelperTest.php 1022 B

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