}); it('should change the text of a node', function () { $xml = new FluidXml(); $cx = $xml->appendChild('p', true); $cx->setText('Document Text'); $expected = "<doc>\n" . " <p>Document Text</p>\n" . "</doc>"; assert_equal_xml($xml, $expected); $cx->setText('Document New Text'); $expected = "<doc>\n" . " <p>Document New Text</p>\n" . "</doc>"; assert_equal_xml($xml, $expected); }); }); describe('.appendCdata', function () { it('should add CDATA to the root node', function () { $xml = new FluidXml(); $xml->appendCdata('// <, > and & are characters that should be escaped in a XML context.'); $expected = "<doc>" . "<![CDATA[// <, > and & are characters that should be escaped in a XML context.]]>" . "</doc>"; assert_equal_xml($xml, $expected); $xml->appendCdata('// <second &cdata section>'); $expected = "<doc>" . "<![CDATA[// <, > and & are characters that should be escaped in a XML context.]]>" . "<![CDATA[// <second &cdata section>]]>" . "</doc>"; assert_equal_xml($xml, $expected); }); it('should add CDATA to a node', function () { $xml = new FluidXml(); $cx = $xml->appendChild('pre', true); $cx->appendCdata('// <, > and & are characters that should be escaped in a XML context.'); $expected = "<doc>\n" . " <pre><![CDATA[// <, > and & are characters that should be escaped in a XML context.]]></pre>\n" . "</doc>"; assert_equal_xml($xml, $expected); $cx->appendCdata('// <second &cdata section>'); $expected = "<doc>\n" . " <pre><![CDATA[// <, > and & are characters that should be escaped in a XML context.]]>" . "<![CDATA[// <second &cdata section>]]>" . "</pre>\n" . "</doc>"; assert_equal_xml($xml, $expected);