\assert($actual === $expected, __($actual, $expected)); }); it('should accept an array of DOMNode', function () { $xml = new FluidXml(); $cx = $xml->appendChild(['head', 'body'], true); $doc = new FluidDocument(); $handler = new FluidInsertionHandler($doc); $new_cx = new FluidContext($doc, $handler, $cx->asArray()); $actual = $new_cx->asArray(); $expected = $cx->asArray(); \assert($actual === $expected, __($actual, $expected)); }); it('should accept a DOMNodeList', function () { $xml = new FluidXml(); $cx = $xml->appendChild(['head', 'body'], true); $dom = $xml->dom(); $domxp = new \DOMXPath($dom); $nodes = $domxp->query('/doc/*'); $doc = new FluidDocument(); $handler = new FluidInsertionHandler($doc); $new_cx = new FluidContext($doc, $handler, $nodes); $actual = $new_cx->asArray(); $expected = $cx->asArray(); \assert($actual === $expected, __($actual, $expected)); }); it('should accept a FluidContext', function () { $xml = new FluidXml(); $cx = $xml->appendChild(['head', 'body'], true); $doc = new FluidDocument(); $handler = new FluidInsertionHandler($doc); $new_cx = new FluidContext($doc, $handler, $cx);
\assert($actual === $expected, __($actual, $expected)); }); }); describe(':domnodelistToString()', function () { it('should convert a DOMNodeList instance to an XML string', function () { $xml = new FluidXml(); $nodes = $xml->dom()->childNodes; $actual = FluidHelper::domnodelistToString($nodes); $expected = "<doc/>"; \assert($actual === $expected, __($actual, $expected)); }); }); describe(':domnodesToString()', function () { it('should convert an array of DOMNode instances to an XML string', function () { $xml = new FluidXml(); $nodes = [$xml->dom()->documentElement]; $actual = FluidHelper::domnodesToString($nodes); $expected = "<doc/>"; \assert($actual === $expected, __($actual, $expected)); }); }); describe('simplexmlToStringWithoutHeaders()', function () { it('should convert a SimpleXMLElement instance to an XML string without the XML headers (declaration and stylesheets)', function () { $xml = \simplexml_import_dom((new FluidXml())->dom()); $actual = FluidHelper::simplexmlToStringWithoutHeaders($xml); $expected = "<doc/>"; \assert($actual === $expected, __($actual, $expected)); }); }); }); describe('CssTranslator', function () {