<?php
+/**
+ * @group Xml
+ */
class XmlTest extends MediaWikiTestCase {
- private static $oldLang;
- private static $oldNamespaces;
protected function setUp() {
parent::setUp();
$this->setMwGlobals( array(
'wgLang' => $langObj,
- 'wgHtml5' => true,
'wgWellFormedXml' => true,
) );
}
+ /**
+ * @covers Xml::expandAttributes
+ */
public function testExpandAttributes() {
$this->assertNull( Xml::expandAttributes( null ),
'Converting a null list of attributes'
);
}
+ /**
+ * @covers Xml::expandAttributes
+ */
public function testExpandAttributesException() {
$this->setExpectedException( 'MWException' );
Xml::expandAttributes( 'string' );
}
+ /**
+ * @covers Xml::element
+ */
function testElementOpen() {
$this->assertEquals(
'<element>',
);
}
+ /**
+ * @covers Xml::element
+ */
function testElementEmpty() {
$this->assertEquals(
'<element />',
);
}
+ /**
+ * @covers Xml::input
+ */
function testElementInputCanHaveAValueOfZero() {
$this->assertEquals(
'<input name="name" value="0" />',
);
}
+ /**
+ * @covers Xml::element
+ */
function testElementEscaping() {
$this->assertEquals(
'<element>hello <there> you & you</element>',
);
}
+ /**
+ * @covers Xml::escapeTagsOnly
+ */
public function testEscapeTagsOnly() {
$this->assertEquals( '"><', Xml::escapeTagsOnly( '"><' ),
'replace " > and < with their HTML entitites'
);
}
+ /**
+ * @covers Xml::element
+ */
function testElementAttributes() {
$this->assertEquals(
'<element key="value" <>="<>">',
);
}
+ /**
+ * @covers Xml::openElement
+ */
function testOpenElement() {
$this->assertEquals(
'<element k="v">',
);
}
+ /**
+ * @covers Xml::closeElement
+ */
function testCloseElement() {
$this->assertEquals( '</element>', Xml::closeElement( 'element' ), 'closeElement() shortcut' );
}
+ /**
+ * @covers Xml::dateMenu
+ */
public function testDateMenu() {
$curYear = intval( gmdate( 'Y' ) );
$prevYear = $curYear - 1;
);
}
- #
- # textarea
- #
+ /**
+ * @covers Xml::textarea
+ */
function testTextareaNoContent() {
$this->assertEquals(
'<textarea name="name" id="name" cols="40" rows="5"></textarea>',
);
}
+ /**
+ * @covers Xml::textarea
+ */
function testTextareaAttribs() {
$this->assertEquals(
'<textarea name="name" id="name" cols="20" rows="10"><txt></textarea>',
);
}
- #
- # input and label
- #
+ /**
+ * @covers Xml::label
+ */
function testLabelCreation() {
$this->assertEquals(
'<label for="id">name</label>',
);
}
+ /**
+ * @covers Xml::label
+ */
function testLabelAttributeCanOnlyBeClassOrTitle() {
$this->assertEquals(
'<label for="id">name</label>',
);
}
+ /**
+ * @covers Xml::languageSelector
+ */
function testLanguageSelector() {
$select = Xml::languageSelector( 'en', true, null,
array( 'id' => 'testlang' ), wfMessage( 'yourlanguage' ) );
);
}
- #
- # JS
- #
+ /**
+ * @covers Xml::escapeJsString
+ */
function testEscapeJsStringSpecialChars() {
$this->assertEquals(
'\\\\\r\n',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarBoolean() {
$this->assertEquals(
'true',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarNull() {
$this->assertEquals(
'null',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarArray() {
$this->assertEquals(
'["a",1]',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarObject() {
$this->assertEquals(
'{"a":"a","b":1}',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarInt() {
$this->assertEquals(
'123456',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarFloat() {
$this->assertEquals(
'1.23456',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarIntString() {
$this->assertEquals(
'"123456"',
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
function testEncodeJsVarFloatString() {
$this->assertEquals(
'"1.23456"',