$xml = new FluidXml(); $xml->setCdata('Text1')->addChild('child', true)->setCdata('Text2'); $alias = new FluidXml(); $alias->cdata('Text1')->addChild('child', true)->cdata('Text2'); $actual = $xml->xml(); $expected = $alias->xml(); \assert($actual === $expected, __($actual, $expected)); }); }); describe('.addCdata()', function () { it('should be fluid', function () { assert_is_fluid('addCdata', 'a'); }); it('should add CDATA to the root node', function () { $xml = new FluidXml(); $xml->addCdata('// <, > are characters that should be escaped in a XML context.')->addCdata('// Even & is a characters that should be escaped in a XML context.'); $expected = "<doc>" . "<![CDATA[// <, > are characters that should be escaped in a XML context.]]>" . "<![CDATA[// Even & is a characters that should be escaped in a XML context.]]>" . "</doc>"; assert_equal_xml($xml, $expected); }); it('should add CDATA to a node', function () { $xml = new FluidXml(); $cx = $xml->addChild('pre', true); $cx->addCdata('// <, > are characters that should be escaped in a XML context.')->addCdata('// Even & is a characters that should be escaped in a XML context.'); $expected = "<doc>\n" . " <pre>" . "<![CDATA[// <, > are characters that should be escaped in a XML context.]]>" . "<![CDATA[// Even & is a characters that should be escaped in a XML context.]]>" . "</pre>\n" . "</doc>"; assert_equal_xml($xml, $expected); }); }); describe('.setComment()', function () { it('should be fluid', function () { assert_is_fluid('setComment', 'a'); });