-
-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathDumper.toText().specials.dom.php84.phpt
110 lines (90 loc) · 1.97 KB
/
Dumper.toText().specials.dom.php84.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* Test: Tracy\Dumper::toText() & Dom
* @phpversion 8.4
*/
declare(strict_types=1);
use Tester\Assert;
use Tracy\Dumper;
require __DIR__ . '/../bootstrap.php';
$dom = Dom\HTMLDocument::createFromString('<!doctype html><ul><li class="a">Ahoj</ul>', Dom\HTML_NO_DEFAULT_NS);
$xpath = new Dom\XPath($dom);
$nodeList = $xpath->query('//li');
$namedNodeMap = $nodeList->item(0)->attributes;
$collection = $dom->getElementsByTagName('li');
$element = $nodeList->item(0);
Assert::match(
<<<'XX'
Dom\HTMLDocument #%d%
URL: 'about:blank'
baseURI: 'about:blank'
%A%
doctype: Dom\DocumentType #%d%
| attributes: null
| baseURI: 'about:blank'
| childNodes: %a%
| entities: Dom\DtdNamedNodeMap #%d% ...
| firstChild: null
%A%
documentElement: Dom\Element #%d%
%A%
XX,
Dumper::toText($dom, [Dumper::DEPTH => 2]),
);
Assert::match(
<<<'XX'
Dom\NodeList #%d%
length: 1
items: array (1)
| 0 => Dom\Element #%d% ...
XX,
Dumper::toText($nodeList, [Dumper::DEPTH => 2]),
);
Assert::match(
<<<'XX'
Dom\NamedNodeMap #%d%
length: 1
items: array (1)
| 'class' => Dom\Attr #%d%
| | attributes: null
%A%
XX,
Dumper::toText($namedNodeMap, [Dumper::DEPTH => 3]),
);
Assert::match(
<<<'XX'
Dom\HTMLCollection #%d%
length: 1
items: array (1)
| 'li' => Dom\Element #%d% ...
XX,
Dumper::toText($collection, [Dumper::DEPTH => 2]),
);
Assert::match(
<<<'XX'
Dom\Element #%d%
attributes: Dom\NamedNodeMap #%d% ...
baseURI: 'about:blank'
%A%
previousSibling: null
substitutedNodeValue: 'Ahoj'
tagName: 'li'
textContent: 'Ahoj'
XX,
Dumper::toText($element, [Dumper::DEPTH => 1]),
);
Assert::match(
<<<'XX'
Dom\TokenList #%d%
length: 1
items: array (1)
| 0 => 'a'
XX,
Dumper::toText($element->classList, [Dumper::DEPTH => 2]),
);
Assert::match(
<<<'XX'
Dom\XPath #%d%%A%
XX,
Dumper::toText($xpath, [Dumper::DEPTH => 1]),
);