|
| 1 | +--TEST-- |
| 2 | +textContent edge cases |
| 3 | +--EXTENSIONS-- |
| 4 | +dom |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +$dom = DOM\XMLDocument::createFromString('<container>text<?pi value?></container>'); |
| 9 | + |
| 10 | +echo "document text content: "; |
| 11 | +var_dump($dom->textContent); |
| 12 | +try { |
| 13 | + $dom->textContent = "foo"; |
| 14 | +} catch (Error $e) { |
| 15 | + echo $e->getMessage(), "\n"; |
| 16 | +} |
| 17 | + |
| 18 | +$container = $dom->documentElement; |
| 19 | + |
| 20 | +$text = $container->firstChild; |
| 21 | +$pi = $text->nextSibling; |
| 22 | + |
| 23 | +echo "text node text content: "; |
| 24 | +var_dump($text->textContent); |
| 25 | +echo "pi node text content: "; |
| 26 | +var_dump($pi->textContent); |
| 27 | + |
| 28 | +$text->textContent = NULL; |
| 29 | +$pi->textContent = NULL; |
| 30 | + |
| 31 | +echo "text node text content: "; |
| 32 | +var_dump($text->textContent); |
| 33 | +echo "pi node text content: "; |
| 34 | +var_dump($pi->textContent); |
| 35 | + |
| 36 | +$container->textContent = NULL; |
| 37 | +echo $dom->saveXML(), "\n"; |
| 38 | + |
| 39 | +?> |
| 40 | +--EXPECT-- |
| 41 | +document text content: NULL |
| 42 | +Cannot modify readonly property DOM\XMLDocument::$textContent |
| 43 | +text node text content: string(4) "text" |
| 44 | +pi node text content: string(5) "value" |
| 45 | +text node text content: string(0) "" |
| 46 | +pi node text content: string(0) "" |
| 47 | +<?xml version="1.0" encoding="UTF-8"?> |
| 48 | +<container></container> |
0 commit comments