| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
XML_Util::createStartElement() basic tests
|
|
|
3 |
--CREDITS--
|
|
|
4 |
Chuck Burgess <ashnazg@php.net>
|
|
|
5 |
# created for v1.2.0a1 2008-05-04
|
|
|
6 |
--FILE--
|
|
|
7 |
<?php
|
|
|
8 |
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util.php';
|
|
|
9 |
echo '=====XML_Util::createStartElement() basic tests=====' . PHP_EOL . PHP_EOL;
|
|
|
10 |
|
|
|
11 |
echo "TEST: tag only" . PHP_EOL;
|
|
|
12 |
echo XML_Util::createStartElement(
|
|
|
13 |
"myNs:myTag"
|
|
|
14 |
) . PHP_EOL . PHP_EOL;
|
|
|
15 |
|
|
|
16 |
echo "TEST: tag with attributes" . PHP_EOL;
|
|
|
17 |
echo XML_Util::createStartElement(
|
|
|
18 |
"myNs:myTag",
|
|
|
19 |
array("foo" => "bar")
|
|
|
20 |
) . PHP_EOL . PHP_EOL;
|
|
|
21 |
|
|
|
22 |
echo "TEST: tag only, passing '' as attribute arg" . PHP_EOL;
|
|
|
23 |
echo XML_Util::createStartElement(
|
|
|
24 |
'myNs:myTag',
|
|
|
25 |
''
|
|
|
26 |
) . PHP_EOL . PHP_EOL;
|
|
|
27 |
|
|
|
28 |
echo "TEST: tag with attributes and namespace" . PHP_EOL;
|
|
|
29 |
echo XML_Util::createStartElement(
|
|
|
30 |
"myNs:myTag",
|
|
|
31 |
array("foo" => "bar"),
|
|
|
32 |
"http://www.w3c.org/myNs#"
|
|
|
33 |
) . PHP_EOL . PHP_EOL;
|
|
|
34 |
|
|
|
35 |
echo "TEST: tag with empty attributes, whose namespaceUri is not a full namespace" . PHP_EOL;
|
|
|
36 |
echo XML_Util::createStartElement(
|
|
|
37 |
'myTag',
|
|
|
38 |
'',
|
|
|
39 |
'foo'
|
|
|
40 |
) . PHP_EOL . PHP_EOL;
|
|
|
41 |
|
|
|
42 |
echo "TEST: tag with attributes, namespace, and multiline = true" . PHP_EOL;
|
|
|
43 |
echo XML_Util::createStartElement(
|
|
|
44 |
"myNs:myTag",
|
|
|
45 |
array("foo" => "bar"),
|
|
|
46 |
"http://www.w3c.org/myNs#",
|
|
|
47 |
true
|
|
|
48 |
) . PHP_EOL . PHP_EOL;
|
|
|
49 |
|
|
|
50 |
echo "TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)" . PHP_EOL;
|
|
|
51 |
echo XML_Util::createStartElement(
|
|
|
52 |
"myNs:myTag",
|
|
|
53 |
array("foo" => "bar"),
|
|
|
54 |
"http://www.w3c.org/myNs#",
|
|
|
55 |
true,
|
|
|
56 |
' '
|
|
|
57 |
) . PHP_EOL . PHP_EOL;
|
|
|
58 |
|
|
|
59 |
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'" . PHP_EOL;
|
|
|
60 |
echo XML_Util::createStartElement(
|
|
|
61 |
"myNs:myTag",
|
|
|
62 |
array("foo" => "bar"),
|
|
|
63 |
"http://www.w3c.org/myNs#",
|
|
|
64 |
true,
|
|
|
65 |
' ',
|
|
|
66 |
'^'
|
|
|
67 |
) . PHP_EOL . PHP_EOL;
|
|
|
68 |
|
|
|
69 |
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true" . PHP_EOL;
|
|
|
70 |
echo XML_Util::createStartElement(
|
|
|
71 |
"myNs:myTag",
|
|
|
72 |
array("foo" => "bar", "boo" => "baz"),
|
|
|
73 |
"http://www.w3c.org/myNs#",
|
|
|
74 |
true,
|
|
|
75 |
' ',
|
|
|
76 |
'^',
|
|
|
77 |
true
|
|
|
78 |
) . PHP_EOL . PHP_EOL;
|
|
|
79 |
|
|
|
80 |
echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false" . PHP_EOL;
|
|
|
81 |
echo XML_Util::createStartElement(
|
|
|
82 |
"myNs:myTag",
|
|
|
83 |
array("foo" => "bar", "boo" => "baz"),
|
|
|
84 |
"http://www.w3c.org/myNs#",
|
|
|
85 |
true,
|
|
|
86 |
' ',
|
|
|
87 |
'^',
|
|
|
88 |
false
|
|
|
89 |
) . PHP_EOL . PHP_EOL;
|
|
|
90 |
?>
|
|
|
91 |
--EXPECT--
|
|
|
92 |
=====XML_Util::createStartElement() basic tests=====
|
|
|
93 |
|
|
|
94 |
TEST: tag only
|
|
|
95 |
<myNs:myTag>
|
|
|
96 |
|
|
|
97 |
TEST: tag with attributes
|
|
|
98 |
<myNs:myTag foo="bar">
|
|
|
99 |
|
|
|
100 |
TEST: tag only, passing '' as attribute arg
|
|
|
101 |
<myNs:myTag>
|
|
|
102 |
|
|
|
103 |
TEST: tag with attributes and namespace
|
|
|
104 |
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">
|
|
|
105 |
|
|
|
106 |
TEST: tag with empty attributes, whose namespaceUri is not a full namespace
|
|
|
107 |
<myTag xmlns="foo">
|
|
|
108 |
|
|
|
109 |
TEST: tag with attributes, namespace, and multiline = true
|
|
|
110 |
<myNs:myTag foo="bar"
|
|
|
111 |
xmlns:myNs="http://www.w3c.org/myNs#">
|
|
|
112 |
|
|
|
113 |
TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)
|
|
|
114 |
<myNs:myTag foo="bar"
|
|
|
115 |
xmlns:myNs="http://www.w3c.org/myNs#">
|
|
|
116 |
|
|
|
117 |
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'
|
|
|
118 |
<myNs:myTag foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
|
|
119 |
|
|
|
120 |
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true
|
|
|
121 |
<myNs:myTag boo="baz"^ foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">
|
|
|
122 |
|
|
|
123 |
TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false
|
|
|
124 |
<myNs:myTag foo="bar"^ boo="baz"^ xmlns:myNs="http://www.w3c.org/myNs#">
|