6 * @license GPL-2.0-or-later
8 * @author Thiemo Mättig
10 class HTMLFormTest
extends MediaWikiTestCase
{
12 private function newInstance() {
13 $form = new HTMLForm( [] );
14 $form->setTitle( Title
::newFromText( 'Foo' ) );
18 public function testGetHTML_empty() {
19 $form = $this->newInstance();
21 $html = $form->getHTML( false );
22 $this->assertStringStartsWith( '<form ', $html );
26 * @expectedException LogicException
28 public function testGetHTML_noPrepare() {
29 $form = $this->newInstance();
30 $form->getHTML( false );
33 public function testAutocompleteDefaultsToNull() {
34 $form = $this->newInstance();
35 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
38 public function testAutocompleteWhenSetToNull() {
39 $form = $this->newInstance();
40 $form->setAutocomplete( null );
41 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
44 public function testAutocompleteWhenSetToFalse() {
45 $form = $this->newInstance();
46 // Previously false was used instead of null to indicate the attribute should not be set
47 $form->setAutocomplete( false );
48 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
51 public function testAutocompleteWhenSetToOff() {
52 $form = $this->newInstance();
53 $form->setAutocomplete( 'off' );
54 $this->assertContains( ' autocomplete="off"', $form->wrapForm( '' ) );
57 public function testGetPreText() {
59 $form = $this->newInstance();
60 $form->setPreText( $preText );
61 $this->assertSame( $preText, $form->getPreText() );