<?php
/**
- * Unit tests for HTMLAutoCompleteSelectField
- *
* @covers HTMLAutoCompleteSelectField
*/
-class HtmlAutoCompleteSelectFieldTest extends MediaWikiTestCase {
+class HTMLAutoCompleteSelectFieldTest extends MediaWikiTestCase {
- var $options = array(
+ public $options = [
'Bulgaria' => 'BGR',
'Burkina Faso' => 'BFA',
'Burundi' => 'BDI',
- );
+ ];
/**
* Verify that attempting to instantiate an HTMLAutoCompleteSelectField
* @expectedExceptionMessage called without any autocompletions
*/
function testMissingAutocompletions() {
- new HTMLAutoCompleteSelectField( array( 'fieldname' => 'Test' ) );
+ new HTMLAutoCompleteSelectField( [ 'fieldname' => 'Test' ] );
}
/**
* @covers HTMLAutoCompleteSelectField::getAttributes
*/
function testGetAttributes() {
- $field = new HTMLAutoCompleteSelectField( array(
+ $field = new HTMLAutoCompleteSelectField( [
'fieldname' => 'Test',
'autocomplete' => $this->options,
- ) );
+ ] );
- $attributes = $field->getAttributes( array() );
+ $attributes = $field->getAttributes( [] );
$this->assertEquals( array_keys( $this->options ),
FormatJson::decode( $attributes['data-autocomplete'] ),
"The 'data-autocomplete' attribute encodes autocomplete option keys as a JSON array."
* the presence or absence of the 'options' parameter.
*/
function testOptionalSelectElement() {
- $params = array(
- 'fieldname' => 'Test',
- 'autocomplete' => $this->options,
- 'options' => $this->options,
- );
+ $params = [
+ 'fieldname' => 'Test',
+ 'autocomplete-data' => $this->options,
+ 'options' => $this->options,
+ ];
$field = new HTMLAutoCompleteSelectField( $params );
$html = $field->getInputHTML( false );