X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FXmlTest.php;h=ab9abbb429be10cb059f10a0c1f63854afb89e04;hb=0705929343a7fbd3417a475cd0c9a0dfe53c3dc4;hp=e46fc67f73658f60f072f1e7bfccd5bb10ae3cb6;hpb=e69bcfad17d67da5113cdd75276a5f7b5cefb123;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php
index e46fc67f73..ab9abbb429 100644
--- a/tests/phpunit/includes/XmlTest.php
+++ b/tests/phpunit/includes/XmlTest.php
@@ -97,8 +97,8 @@ class XmlTest extends MediaWikiTestCase {
*/
public function testElementEscaping() {
$this->assertEquals(
- 'hello <there> you & you',
- Xml::element( 'element', null, 'hello you & you' ),
+ '"hello <there> your\'s & you"',
+ Xml::element( 'element', null, '"hello your\'s & you"' ),
'Element with no attributes and content that needs escaping'
);
}
@@ -454,6 +454,34 @@ class XmlTest extends MediaWikiTestCase {
);
}
+ /**
+ * @covers Xml::encodeJsVar
+ */
+ public function testXmlJsCode() {
+ $code = 'function () { foo( 42 ); }';
+ $this->assertEquals(
+ $code,
+ Xml::encodeJsVar( new XmlJsCode( $code ) )
+ );
+ }
+
+ /**
+ * @covers Xml::encodeJsVar
+ * @covers XmlJsCode::encodeObject
+ */
+ public function testEncodeObject() {
+ $codeA = 'function () { foo( 42 ); }';
+ $codeB = 'function ( jQuery ) { bar( 142857 ); }';
+ $obj = XmlJsCode::encodeObject( [
+ 'a' => new XmlJsCode( $codeA ),
+ 'b' => new XmlJsCode( $codeB )
+ ] );
+ $this->assertEquals(
+ "{\"a\":$codeA,\"b\":$codeB}",
+ Xml::encodeJsVar( $obj )
+ );
+ }
+
/**
* @covers Xml::listDropDown
*/