xref: /php-src/ext/dom/tests/not_serializable.phpt (revision 14b6c981)
1--TEST--
2DOM classes are not serializable
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$doc = new DOMDocument();
9$doc->loadXML('<root><node/></root>');
10try {
11    serialize($doc);
12} catch (Exception $e) {
13    echo $e->getMessage(), "\n";
14}
15
16$node = $doc->documentElement;
17try {
18    serialize($node);
19} catch (Exception $e) {
20    echo $e->getMessage(), "\n";
21}
22
23$xpath = new DOMXPath($doc);
24try {
25    serialize($xpath);
26} catch (Exception $e) {
27    echo $e->getMessage(), "\n";
28}
29
30$ns = $xpath->query('//namespace::*')->item(0);
31try {
32    serialize($ns);
33} catch (Exception $e) {
34    echo $e->getMessage(), "\n";
35}
36
37$dom = DOM\XMLDocument::createEmpty();
38try {
39    serialize($dom);
40} catch (Exception $e) {
41    echo $e->getMessage(), "\n";
42}
43
44try {
45    serialize(new DOM\XPath($dom));
46} catch (Exception $e) {
47    echo $e->getMessage(), "\n";
48}
49
50?>
51--EXPECT--
52Serialization of 'DOMDocument' is not allowed, unless serialization methods are implemented in a subclass
53Serialization of 'DOMElement' is not allowed, unless serialization methods are implemented in a subclass
54Serialization of 'DOMXPath' is not allowed
55Serialization of 'DOMNameSpaceNode' is not allowed, unless serialization methods are implemented in a subclass
56Serialization of 'DOM\XMLDocument' is not allowed, unless serialization methods are implemented in a subclass
57Serialization of 'DOM\XPath' is not allowed
58