* Strip comments early, before template expansion. This mimics the behaviour in the...
[mediawiki.git] / t / inc / Xml.t
blob527cd7f569536649211e3e171ba497c7e7a403e4
1 #!/usr/bin/env php
2 <?php
4 require 'Test.php';
6 plan( 8 );
8 require_ok( 'includes/Sanitizer.php' );
9 require_ok( 'includes/Xml.php' );
12 # element
15 cmp_ok(
16 Xml::element( 'element', null, null ),
17 '==',
18 '<element>',
19 'Opening element with no attributes'
22 cmp_ok(
23 Xml::element( 'element', null, '' ),
24 '==',
25 '<element />',
26 'Terminated empty element'
29 cmp_ok(
30 Xml::element( 'element', null, 'hello <there> you & you' ),
31 '==',
32 '<element>hello &lt;there&gt; you &amp; you</element>',
33 'Element with no attributes and content that needs escaping'
36 cmp_ok(
37 Xml::element( 'element', array( 'key' => 'value', '<>' => '<>' ), null ),
38 '==',
39 '<element key="value" <>="&lt;&gt;">',
40 'Element attributes, keys are not escaped'
44 # open/close element
47 cmp_ok(
48 Xml::openElement( 'element', array( 'k' => 'v' ) ),
49 '==',
50 '<element k="v">',
51 'openElement() shortcut'
54 cmp_ok( Xml::closeElement( 'element' ), '==', '</element>', 'closeElement() shortcut' );
56 /* vim: set filetype=php: */