assertEquals( '', Xml::element( 'element', null, null ), 'Opening element with no attributes' ); } function testElementEmpty() { $this->assertEquals( '', Xml::element( 'element', null, '' ), 'Terminated empty element' ); } function testElementEscaping() { $this->assertEquals( 'hello <there> you & you', Xml::element( 'element', null, 'hello you & you' ), 'Element with no attributes and content that needs escaping' ); } function testElementAttributes() { $this->assertEquals( '="<>">', Xml::element( 'element', array( 'key' => 'value', '<>' => '<>' ), null ), 'Element attributes, keys are not escaped' ); } function testOpenElement() { $this->assertEquals( '', Xml::openElement( 'element', array( 'k' => 'v' ) ), 'openElement() shortcut' ); } function testCloseElement() { $this->assertEquals( '', Xml::closeElement( 'element' ), 'closeElement() shortcut' ); } # # textarea # function testTextareaNoContent() { $this->assertEquals( '', Xml::textarea( 'name', '' ), 'textarea() with not content' ); } function testTextareaAttribs() { $this->assertEquals( '', Xml::textarea( 'name', '', 20, 10 ), 'textarea() with custom attribs' ); } # # JS # function testEscapeJsStringSpecialChars() { $this->assertEquals( '\\\\\r\n', Xml::escapeJsString( "\\\r\n" ), 'escapeJsString() with special characters' ); } function testEncodeJsVarBoolean() { $this->assertEquals( 'true', Xml::encodeJsVar( true ), 'encodeJsVar() with boolean' ); } function testEncodeJsVarNull() { $this->assertEquals( 'null', Xml::encodeJsVar( null ), 'encodeJsVar() with null' ); } function testEncodeJsVarArray() { $this->assertEquals( '["a", 1]', Xml::encodeJsVar( array( 'a', 1 ) ), 'encodeJsVar() with array' ); $this->assertEquals( '{"a": "a", "b": 1}', Xml::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ), 'encodeJsVar() with associative array' ); } function testEncodeJsVarObject() { $this->assertEquals( '{"a": "a", "b": 1}', Xml::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ), 'encodeJsVar() with object' ); } }