wiki.techinc.nl/tests/phpunit/unit/includes/LicensesTest.php
Brian Wolff 07cdef809c Deprecate creating HTMLFormFields without reference to parent form
Currently it is documented that mParent in HTMLFormField may be null.
This can happen if the form element is constructed manually via
new, instead of the normal way via HTMLForm methods.

As it stands, much of the code assumes that mParent is always set
despite the documentation. Lets mark creating form fields without
parent set as deprecated. The current situation seems like a
recipe for bugs, and after the deprecation period this would allow
us to simplify some of the HTMLFormField code.

Bug: T326456
Change-Id: Ica0740049f0a3e8ec764903c5b71825e4d628a3f
Depends-On: I15a39605e3eec8a5c265c4a331039fa906eda036
2023-01-08 18:20:16 -08:00

28 lines
594 B
PHP

<?php
/**
* @covers Licenses
*/
class LicensesTest extends MediaWikiUnitTestCase {
public function testLicenses() {
$str = "
* Free licenses:
** GFDL|Debian disagrees
";
$htmlform = $this->createMock( HTMLForm::class );
$lc = new Licenses( [
'fieldname' => 'FooField',
'type' => 'select',
'section' => 'description',
'id' => 'wpLicense',
'label' => 'A label text', # Note can't test label-message because $wgOut is not defined
'name' => 'AnotherName',
'licenses' => $str,
'parent' => $htmlform
] );
$this->assertInstanceOf( Licenses::class, $lc );
}
}