$xml->query('/doc/*')->each('eachsettext'); $expected = "<doc>\n" . " <child1>child11</child1>\n" . " <child2>child22</child2>\n" . "</doc>"; assert_equal_xml($xml, $expected); }); }); describe('.filter()', function () { it('should be fluid', function () { assert_is_fluid('filter', function () { }); }); it('should filter the nodes inside the context', function () { $xml = new FluidXml(); $xml->filter(function ($i, $n) { assert_is_a($this, FluidContext::class); assert_is_a($n, \DOMNode::class); $actual = $i; $expected = 0; \assert($actual === $expected, __($actual, $expected)); }); function filterassert($cx, $i, $n) { assert_is_a($cx, FluidContext::class); assert_is_a($n, \DOMNode::class); $actual = $i; $expected = 0; \assert($actual === $expected, __($actual, $expected)); } $xml->each('filterassert'); $xml->times(4)->addChild('child'); $index = 0; $children = $xml->query('//child');