FormHelperTest.php 946 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. public $Form;
  13. public function setUp() {
  14. parent::setUp();
  15. Configure::delete('FormConfig');
  16. $this->View = new View(null);
  17. $this->Form = new FormHelper($this->View);
  18. }
  19. /**
  20. * test novalidate for create
  21. *
  22. * @return void
  23. */
  24. public function testCreate() {
  25. $expected = 'novalidate="novalidate"';
  26. $result = $this->Form->create();
  27. $this->assertNotContains($expected, $result);
  28. Configure::write('FormConfig.novalidate', true);
  29. $this->Form = new FormHelper($this->View);
  30. $result = $this->Form->create();
  31. $this->assertContains($expected, $result);
  32. $result = $this->Form->create(null, ['novalidate' => false]);
  33. $this->assertNotContains($expected, $result);
  34. }
  35. }