Merge "[MCR] Revision::newFromArchiveRow remove recently added $title param"
[lhc/web/wiklou.git] / tests / phpunit / includes / htmlform / HTMLFormTest.php
1 <?php
2
3 /**
4 * @covers HTMLForm
5 *
6 * @licence GNU GPL v2+
7 * @author Gergő Tisza
8 * @author Thiemo Mättig
9 */
10 class HTMLFormTest extends MediaWikiTestCase {
11
12 private function newInstance() {
13 $form = new HTMLForm( [] );
14 $form->setTitle( Title::newFromText( 'Foo' ) );
15 return $form;
16 }
17
18 public function testGetHTML_empty() {
19 $form = $this->newInstance();
20 $form->prepareForm();
21 $html = $form->getHTML( false );
22 $this->assertStringStartsWith( '<form ', $html );
23 }
24
25 /**
26 * @expectedException LogicException
27 */
28 public function testGetHTML_noPrepare() {
29 $form = $this->newInstance();
30 $form->getHTML( false );
31 }
32
33 public function testAutocompleteDefaultsToNull() {
34 $form = $this->newInstance();
35 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
36 }
37
38 public function testAutocompleteWhenSetToNull() {
39 $form = $this->newInstance();
40 $form->setAutocomplete( null );
41 $this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
42 }
43
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( '' ) );
49 }
50
51 public function testAutocompleteWhenSetToOff() {
52 $form = $this->newInstance();
53 $form->setAutocomplete( 'off' );
54 $this->assertContains( ' autocomplete="off"', $form->wrapForm( '' ) );
55 }
56
57 }