From 07c688f224a777f61d984d72c9f7ffd531633cfb Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:16:55 +0200 Subject: [PATCH] Add XPath test with a context node --- ext/dom/tests/xpath_context_node.phpt | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 ext/dom/tests/xpath_context_node.phpt diff --git a/ext/dom/tests/xpath_context_node.phpt b/ext/dom/tests/xpath_context_node.phpt new file mode 100644 index 00000000000..8e60c8686d1 --- /dev/null +++ b/ext/dom/tests/xpath_context_node.phpt @@ -0,0 +1,31 @@ +--TEST-- +XPath: with a context node +--EXTENSIONS-- +dom +--FILE-- +loadXML(<< + +

bar

+
+ +

foo1

+

foo2

+
+ +XML); +$xpath = new DOMXpath($dom); + +foreach ($xpath->query("p", $dom->documentElement->firstElementChild->nextElementSibling) as $p) { + echo $p->textContent, "\n"; +} + +var_dump($xpath->evaluate("count(p)", $dom->documentElement->firstElementChild->nextElementSibling)); + +?> +--EXPECT-- +foo1 +foo2 +float(2)