6 * @license GPL-2.0-or-later
9 class HTMLFormTest
extends MediaWikiTestCase
{
11 private function newInstance() {
12 $form = new HTMLForm( [] );
13 $form->setTitle( Title
::newFromText( 'Foo' ) );
17 public function testGetHTML_empty() {
18 $form = $this->newInstance();
20 $html = $form->getHTML( false );
21 $this->assertStringStartsWith( '<form ', $html );
25 * @expectedException LogicException
27 public function testGetHTML_noPrepare() {
28 $form = $this->newInstance();
29 $form->getHTML( false );
32 public function testAutocompleteDefaultsToNull() {
33 $form = $this->newInstance();
34 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
37 public function testAutocompleteWhenSetToNull() {
38 $form = $this->newInstance();
39 $form->setAutocomplete( null );
40 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
43 public function testAutocompleteWhenSetToFalse() {
44 $form = $this->newInstance();
45 // Previously false was used instead of null to indicate the attribute should not be set
46 $form->setAutocomplete( false );
47 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
50 public function testAutocompleteWhenSetToOff() {
51 $form = $this->newInstance();
52 $form->setAutocomplete( 'off' );
53 $this->assertContains( ' autocomplete="off"', $form->wrapForm( '' ) );
56 public function testGetPreText() {
58 $form = $this->newInstance();
59 $form->setPreText( $preText );
60 $this->assertSame( $preText, $form->getPreText() );