parent::setUp();
$langObj = Language::factory( 'en' );
- $langObj->setNamespaces( array(
+ $langObj->setNamespaces( [
-2 => 'Media',
-1 => 'Special',
0 => '',
11 => 'Template_talk',
100 => 'Custom',
101 => 'Custom_talk',
- ) );
+ ] );
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgLang' => $langObj,
- 'wgWellFormedXml' => true,
- ) );
+ 'wgUseMediaWikiUIEverywhere' => false,
+ ] );
}
/**
$this->assertNull( Xml::expandAttributes( null ),
'Converting a null list of attributes'
);
- $this->assertEquals( '', Xml::expandAttributes( array() ),
+ $this->assertEquals( '', Xml::expandAttributes( [] ),
'Converting an empty list of attributes'
);
}
*/
public function testElementInputCanHaveAValueOfZero() {
$this->assertEquals(
- '<input name="name" value="0" class="mw-ui-input" />',
+ '<input name="name" value="0" />',
Xml::input( 'name', false, 0 ),
'Input with a value of 0 (bug 23797)'
);
public function testElementAttributes() {
$this->assertEquals(
'<element key="value" <>="<>">',
- Xml::element( 'element', array( 'key' => 'value', '<>' => '<>' ), null ),
+ Xml::element( 'element', [ 'key' => 'value', '<>' => '<>' ], null ),
'Element attributes, keys are not escaped'
);
}
public function testOpenElement() {
$this->assertEquals(
'<element k="v">',
- Xml::openElement( 'element', array( 'k' => 'v' ) ),
+ Xml::openElement( 'element', [ 'k' => 'v' ] ),
'openElement() shortcut'
);
}
$this->assertEquals(
'<label for="year">From year (and earlier):</label> ' .
- '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" class="mw-ui-input" /> ' .
+ '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
'<label for="month">From month (and earlier):</label> ' .
- '<select id="month" name="month" class="mw-month-selector">' .
+ '<select name="month" id="month" class="mw-month-selector">' .
'<option value="-1">all</option>' . "\n" .
'<option value="1">January</option>' . "\n" .
'<option value="2" selected="">February</option>' . "\n" .
);
$this->assertEquals(
'<label for="year">From year (and earlier):</label> ' .
- '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" class="mw-ui-input" /> ' .
+ '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
'<label for="month">From month (and earlier):</label> ' .
- '<select id="month" name="month" class="mw-month-selector">' .
+ '<select name="month" id="month" class="mw-month-selector">' .
'<option value="-1">all</option>' . "\n" .
'<option value="1">January</option>' . "\n" .
'<option value="2">February</option>' . "\n" .
$this->assertEquals(
'<label for="year">From year (and earlier):</label> ' .
- '<input id="year" maxlength="4" size="7" type="number" name="year" class="mw-ui-input" /> ' .
+ '<input id="year" maxlength="4" size="7" type="number" name="year"/> ' .
'<label for="month">From month (and earlier):</label> ' .
- '<select id="month" name="month" class="mw-month-selector">' .
+ '<select name="month" id="month" class="mw-month-selector">' .
'<option value="-1">all</option>' . "\n" .
'<option value="1">January</option>' . "\n" .
'<option value="2">February</option>' . "\n" .
*/
public function testTextareaNoContent() {
$this->assertEquals(
- '<textarea name="name" id="name" cols="40" rows="5" class="mw-ui-input"></textarea>',
+ '<textarea name="name" id="name" cols="40" rows="5"></textarea>',
Xml::textarea( 'name', '' ),
'textarea() with not content'
);
*/
public function testTextareaAttribs() {
$this->assertEquals(
- '<textarea name="name" id="name" cols="20" rows="10" class="mw-ui-input"><txt></textarea>',
+ '<textarea name="name" id="name" cols="20" rows="10"><txt></textarea>',
Xml::textarea( 'name', '<txt>', 20, 10 ),
'textarea() with custom attribs'
);
public function testLabelAttributeCanOnlyBeClassOrTitle() {
$this->assertEquals(
'<label for="id">name</label>',
- Xml::label( 'name', 'id', array( 'generated' => true ) ),
+ Xml::label( 'name', 'id', [ 'generated' => true ] ),
'label() can not be given a generated attribute'
);
$this->assertEquals(
'<label for="id" class="nice">name</label>',
- Xml::label( 'name', 'id', array( 'class' => 'nice' ) ),
+ Xml::label( 'name', 'id', [ 'class' => 'nice' ] ),
'label() can get a class attribute'
);
$this->assertEquals(
'<label for="id" title="nice tooltip">name</label>',
- Xml::label( 'name', 'id', array( 'title' => 'nice tooltip' ) ),
+ Xml::label( 'name', 'id', [ 'title' => 'nice tooltip' ] ),
'label() can get a title attribute'
);
$this->assertEquals(
'<label for="id" class="nice" title="nice tooltip">name</label>',
- Xml::label( 'name', 'id', array(
+ Xml::label( 'name', 'id', [
'generated' => true,
'class' => 'nice',
'title' => 'nice tooltip',
'anotherattr' => 'value',
- )
+ ]
),
'label() skip all attributes but "class" and "title"'
);
*/
public function testLanguageSelector() {
$select = Xml::languageSelector( 'en', true, null,
- array( 'id' => 'testlang' ), wfMessage( 'yourlanguage' ) );
+ [ 'id' => 'testlang' ], wfMessage( 'yourlanguage' ) );
$this->assertEquals(
'<label for="testlang">Language:</label>',
$select[0]
);
}
- /**
- * @covers Xml::escapeJsString
- */
- public function testEscapeJsStringSpecialChars() {
- $this->assertEquals(
- '\\\\\r\n',
- Xml::escapeJsString( "\\\r\n" ),
- 'escapeJsString() with special characters'
- );
- }
-
/**
* @covers Xml::encodeJsVar
*/
public function testEncodeJsVarArray() {
$this->assertEquals(
'["a",1]',
- Xml::encodeJsVar( array( 'a', 1 ) ),
+ Xml::encodeJsVar( [ 'a', 1 ] ),
'encodeJsVar() with array'
);
$this->assertEquals(
'{"a":"a","b":1}',
- Xml::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ),
+ Xml::encodeJsVar( [ 'a' => 'a', 'b' => 1 ] ),
'encodeJsVar() with associative array'
);
}
public function testEncodeJsVarObject() {
$this->assertEquals(
'{"a":"a","b":1}',
- Xml::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ),
+ Xml::encodeJsVar( (object)[ 'a' => 'a', 'b' => 1 ] ),
'encodeJsVar() with object'
);
}