mirror of
https://github.com/php/php-src.git
synced 2024-11-25 10:54:15 +08:00
Add a "profile" of simplexml's expected behaviour in the form of tests.
This will be expanded as issues arise and will be a formal definition (in code) of simplexml's behaviour.
This commit is contained in:
parent
69e6b296e0
commit
7f5b508f26
18
ext/simplexml/tests/profile01.phpt
Normal file
18
ext/simplexml/tests/profile01.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing a simple node
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root>
|
||||
<child>Hello</child>
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->child;
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello
|
||||
---Done---
|
21
ext/simplexml/tests/profile02.phpt
Normal file
21
ext/simplexml/tests/profile02.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing an array of subnodes
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root>
|
||||
<child>Hello</child>
|
||||
<child>World</child>
|
||||
</root>
|
||||
');
|
||||
|
||||
foreach ($root->child as $child) {
|
||||
echo "$child ";
|
||||
}
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello World
|
||||
---Done---
|
18
ext/simplexml/tests/profile03.phpt
Normal file
18
ext/simplexml/tests/profile03.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing an attribute
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root>
|
||||
<child attribute="Sample" />
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->child['attribute'];
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Sample
|
||||
---Done---
|
18
ext/simplexml/tests/profile04.phpt
Normal file
18
ext/simplexml/tests/profile04.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing a namespaced element
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns">
|
||||
<reserved:child>Hello</reserved:child>
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->reserved->child;
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello
|
||||
---Done---
|
22
ext/simplexml/tests/profile05.phpt
Normal file
22
ext/simplexml/tests/profile05.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing an aliased namespaced element
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns">
|
||||
<reserved:child>Hello</reserved:child>
|
||||
</root>
|
||||
');
|
||||
|
||||
$root->register_ns('myns', 'reserved-ns');
|
||||
|
||||
echo $root->myns->child;
|
||||
echo $root->reserved->child;
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello
|
||||
---Done---
|
19
ext/simplexml/tests/profile06.phpt
Normal file
19
ext/simplexml/tests/profile06.phpt
Normal file
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing a namespaced attribute
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns">
|
||||
<child reserved:attribute="Sample" />
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->child['reserved:attribute'];
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Sample
|
||||
---Done---
|
22
ext/simplexml/tests/profile07.phpt
Normal file
22
ext/simplexml/tests/profile07.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing an aliased namespaced attribute
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns">
|
||||
<child reserved:attribute="Sample" />
|
||||
</root>
|
||||
');
|
||||
|
||||
$root->register_ns('myns', 'reserved-ns');
|
||||
|
||||
echo $root->child['reserved:attribute'];
|
||||
echo $root->child['myns:attribute'];
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Sample
|
||||
---Done---
|
19
ext/simplexml/tests/profile08.phpt
Normal file
19
ext/simplexml/tests/profile08.phpt
Normal file
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing a namespaced attribute without a namespace
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns">
|
||||
<child reserved:attribute="Sample" />
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->child['attribute'];
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
---Done---
|
19
ext/simplexml/tests/profile09.phpt
Normal file
19
ext/simplexml/tests/profile09.phpt
Normal file
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing a namespaced element without a namespace
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns">
|
||||
<reserved:child>Hello</reserved:child>
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->child;
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
---Done---
|
25
ext/simplexml/tests/profile10.phpt
Normal file
25
ext/simplexml/tests/profile10.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing two attributes with the same name, but different namespaces
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns" xmlns:special="special-ns">
|
||||
<child reserved:attribute="Sample" special:attribute="Test" />
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->child['reserved:attribute'];
|
||||
echo "\n";
|
||||
echo $root->child['special:attribute'];
|
||||
foreach ($root->child['attribute'] as $attr) {
|
||||
echo "$attr\n";
|
||||
}
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Sample
|
||||
Test
|
||||
---Done---
|
26
ext/simplexml/tests/profile11.phpt
Normal file
26
ext/simplexml/tests/profile11.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
SimpleXML [profile]: Accessing two elements with the same name, but different namespaces
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
$root = simplexml_load_string('<?xml version="1.0"?>
|
||||
<root xmlns:reserved="reserved-ns" xmlns:special="special-ns">
|
||||
<reserved:child>Hello</reserved:child>
|
||||
<special:child>World</special:child>
|
||||
</root>
|
||||
');
|
||||
|
||||
echo $root->reserved->child;
|
||||
echo "\n";
|
||||
echo $root->special->child;
|
||||
foreach ($root->child as $child) {
|
||||
echo "$child\n";
|
||||
}
|
||||
echo "\n---Done---\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello
|
||||
World
|
||||
---Done---
|
Loading…
Reference in New Issue
Block a user