This changeset implements T89432 and related tickets and is based on exploration done at the Prague Hackathon. The goal is to identify tests in MediaWiki core that can be run without having to install & configure MediaWiki and its dependencies, and provide a way to execute these tests via the standard phpunit entry point, allowing for faster development and integration with existing tooling like IDEs. The initial set of tests that met these criteria were identified using the work Amir did in I88822667693d9e00ac3d4639c87bc24e5083e5e8. These tests were then moved into a new subdirectory under phpunit/ and organized into a separate test suite. The environment for this suite is set up via a PHPUnit bootstrap file without a custom entry point. You can execute these tests by running: $ vendor/bin/phpunit -d memory_limit=512M -c tests/phpunit/unit-tests.xml Bug: T89432 Bug: T87781 Bug: T84948 Change-Id: Iad01033a0548afd4d2a6f2c1ef6fcc9debf72c0d
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @covers HTMLForm
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
* @author Gergő Tisza
|
|
*/
|
|
class HTMLFormTest extends \MediaWikiUnitTestCase {
|
|
|
|
private function newInstance() {
|
|
$form = new HTMLForm( [] );
|
|
$form->setTitle( Title::newFromText( 'Foo' ) );
|
|
return $form;
|
|
}
|
|
|
|
public function testGetHTML_empty() {
|
|
$form = $this->newInstance();
|
|
$form->prepareForm();
|
|
$html = $form->getHTML( false );
|
|
$this->assertStringStartsWith( '<form ', $html );
|
|
}
|
|
|
|
/**
|
|
* @expectedException LogicException
|
|
*/
|
|
public function testGetHTML_noPrepare() {
|
|
$form = $this->newInstance();
|
|
$form->getHTML( false );
|
|
}
|
|
|
|
public function testAutocompleteDefaultsToNull() {
|
|
$form = $this->newInstance();
|
|
$this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
|
|
}
|
|
|
|
public function testAutocompleteWhenSetToNull() {
|
|
$form = $this->newInstance();
|
|
$form->setAutocomplete( null );
|
|
$this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
|
|
}
|
|
|
|
public function testAutocompleteWhenSetToFalse() {
|
|
$form = $this->newInstance();
|
|
// Previously false was used instead of null to indicate the attribute should not be set
|
|
$form->setAutocomplete( false );
|
|
$this->assertNotContains( 'autocomplete', $form->wrapForm( '' ) );
|
|
}
|
|
|
|
public function testAutocompleteWhenSetToOff() {
|
|
$form = $this->newInstance();
|
|
$form->setAutocomplete( 'off' );
|
|
$this->assertContains( ' autocomplete="off"', $form->wrapForm( '' ) );
|
|
}
|
|
|
|
public function testGetPreText() {
|
|
$preText = 'TEST';
|
|
$form = $this->newInstance();
|
|
$form->setPreText( $preText );
|
|
$this->assertSame( $preText, $form->getPreText() );
|
|
}
|
|
|
|
}
|