1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 15:38:49 +02:00
Files
archived-php-src/ext/dom/tests/dom007.phpt
T
Peter Kokot d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00

110 lines
2.3 KiB
PHP

--TEST--
Test 7: DTD tests
--SKIPIF--
<?php
require_once('skipif.inc');
?>
--FILE--
<?php
$xml = <<< EOXML
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE courses [
<!ELEMENT courses (course+)>
<!ELEMENT course (title, description, temp*)>
<!ATTLIST course cid ID #REQUIRED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT temp (#PCDATA)>
<!ATTLIST temp vid ID #REQUIRED>
<!ENTITY test 'http://www.hpl.hp.com/semweb/2003/query_tester#'>
<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!NOTATION GIF PUBLIC "-" "image/gif">
<!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF>
]>
<courses>
<course cid="c1">
<title>Basic Languages</title>
<description>Introduction to Languages</description>
</course>
<course cid="c6">
<title>French I</title>
<description>Introduction to French</description>
<temp vid="c7">
</temp>
</course>
</courses>
EOXML;
$dom = new DOMDocument();
$dom->loadXML($xml);
$dtd = $dom->doctype;
/* Notation Tests */
$nots = $dtd->notations;
$length = $nots->length;
echo "Length: ".$length."\n";
foreach ($nots AS $key=>$node) {
echo "Key $key: ".$node->nodeName." (".$node->systemId.") (".$node->publicId.")\n";
}
print "\n";
for($x=0; $x < $length; $x++) {
echo "Index $x: ".$nots->item($x)->nodeName." (".$nots->item($x)->systemId.") (".$nots->item($x)->publicId.")\n";
}
echo "\n";
$node = $nots->getNamedItem('xxx');
var_dump($node);
echo "\n";
/* Entity Decl Tests */
$ents = $dtd->entities;
$length = $ents->length;
echo "Length: ".$length."\n";
$xkeys = array();
foreach ($ents AS $key=>$node) {
$xkeys[] = "Key: $key Name: ".$node->nodeName."\n";
}
sort($xkeys); // fix inconsistent output ordering (bug #61810)
foreach ($xkeys as $key => $node) {
echo $node;
}
echo "\n";
$xkeys = array();
for($x=0; $x < $length; $x++) {
$xkeys[] = "Index: ".$ents->item($x)->nodeName."\n";
}
sort($xkeys); // fix inconsistent output ordering (bug #61810)
foreach ($xkeys as $key => $node) {
echo $node;
}
echo "\n";
$node = $ents->item(3);
var_dump($node);
$node = $ents->getNamedItem('xxx');
var_dump($node);
--EXPECT--
Length: 1
Key GIF: GIF (image/gif) (-)
Index 0: GIF (image/gif) (-)
NULL
Length: 3
Key: myimage Name: myimage
Key: rdf Name: rdf
Key: test Name: test
Index: myimage
Index: rdf
Index: test
NULL
NULL