3 class XmlTest
extends PHPUnit_Framework_TestCase
{
5 function testElementOpen() {
8 Xml
::element( 'element', null, null ),
9 'Opening element with no attributes'
13 function testElementEmpty() {
16 Xml
::element( 'element', null, '' ),
17 'Terminated empty element'
21 function testElementEscaping() {
23 '<element>hello <there> you & you</element>',
24 Xml
::element( 'element', null, 'hello <there> you & you' ),
25 'Element with no attributes and content that needs escaping'
29 function testElementAttributes() {
31 '<element key="value" <>="<>">',
32 Xml
::element( 'element', array( 'key' => 'value', '<>' => '<>' ), null ),
33 'Element attributes, keys are not escaped'
37 function testOpenElement() {
40 Xml
::openElement( 'element', array( 'k' => 'v' ) ),
41 'openElement() shortcut'
45 function testCloseElement() {
46 $this->assertEquals( '</element>', Xml
::closeElement( 'element' ), 'closeElement() shortcut' );
52 function testTextareaNoContent() {
54 '<textarea name="name" id="name" cols="40" rows="5"></textarea>',
55 Xml
::textarea( 'name', '' ),
56 'textarea() with not content'
60 function testTextareaAttribs() {
62 '<textarea name="name" id="name" cols="20" rows="10"><txt></textarea>',
63 Xml
::textarea( 'name', '<txt>', 20, 10 ),
64 'textarea() with custom attribs'
71 function testEscapeJsStringSpecialChars() {
74 Xml
::escapeJsString( "\\\r\n" ),
75 'escapeJsString() with special characters'
79 function testEncodeJsVarBoolean() {
82 Xml
::encodeJsVar( true ),
83 'encodeJsVar() with boolean'
87 function testEncodeJsVarNull() {
90 Xml
::encodeJsVar( null ),
91 'encodeJsVar() with null'
95 function testEncodeJsVarArray() {
98 Xml
::encodeJsVar( array( 'a', 1 ) ),
99 'encodeJsVar() with array'
102 '{"a": "a", "b": 1}',
103 Xml
::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ),
104 'encodeJsVar() with associative array'
108 function testEncodeJsVarObject() {
110 '{"a": "a", "b": 1}',
111 Xml
::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ),
112 'encodeJsVar() with object'