Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
XML_Util::replaceEntities() 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::replaceEntities() basic tests=====' . PHP_EOL . PHP_EOL;
10
 
11
$data = 'This string contains < & >.';
12
$utf8 = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
13
 
14
echo "TEST:  basic usage" . PHP_EOL;
15
echo XML_Util::replaceEntities($data) . PHP_EOL . PHP_EOL;
16
 
17
echo "TEST:  basic usage but with bogus \$replaceEntities arg" . PHP_EOL;
18
echo XML_Util::replaceEntities($data, 'I_AM_BOGUS') . PHP_EOL . PHP_EOL;
19
 
20
echo "TEST:  basic usage with ENTITIES_XML" . PHP_EOL;
21
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML) . PHP_EOL . PHP_EOL;
22
 
23
echo "TEST:  basic usage with ENTITIES_XML and UTF-8" . PHP_EOL;
24
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
25
 
26
echo "TEST:  utf8 usage with ENTITIES_XML and UTF-8" . PHP_EOL;
27
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_XML, 'UTF-8') . PHP_EOL . PHP_EOL;
28
 
29
echo "TEST:  basic usage with ENTITIES_XML_REQUIRED" . PHP_EOL;
30
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED) . PHP_EOL . PHP_EOL;
31
 
32
echo "TEST:  basic usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
33
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
34
 
35
echo "TEST:  utf8 usage with ENTITIES_XML_REQUIRED and UTF-8" . PHP_EOL;
36
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_XML_REQUIRED, 'UTF-8') . PHP_EOL . PHP_EOL;
37
 
38
echo "TEST:  basic usage with ENTITIES_HTML" . PHP_EOL;
39
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML) . PHP_EOL . PHP_EOL;
40
 
41
echo "TEST:  basic usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
42
echo XML_Util::replaceEntities($data, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
43
 
44
echo "TEST:  utf8 usage with ENTITIES_HTML and UTF-8" . PHP_EOL;
45
echo XML_Util::replaceEntities($utf8, XML_UTIL_ENTITIES_HTML, 'UTF-8') . PHP_EOL . PHP_EOL;
46
?>
47
--EXPECT--
48
=====XML_Util::replaceEntities() basic tests=====
49
 
50
TEST:  basic usage
51
This string contains &lt; &amp; &gt;.
52
 
53
TEST:  basic usage but with bogus $replaceEntities arg
54
This string contains < & >.
55
 
56
TEST:  basic usage with ENTITIES_XML
57
This string contains &lt; &amp; &gt;.
58
 
59
TEST:  basic usage with ENTITIES_XML and UTF-8
60
This string contains &lt; &amp; &gt;.
61
 
62
TEST:  utf8 usage with ENTITIES_XML and UTF-8
63
This data contains special chars like &lt;, &gt;, &amp; and &quot; as well as ä, ö, ß, à and ê
64
 
65
TEST:  basic usage with ENTITIES_XML_REQUIRED
66
This string contains &lt; &amp; >.
67
 
68
TEST:  basic usage with ENTITIES_XML_REQUIRED and UTF-8
69
This string contains &lt; &amp; >.
70
 
71
TEST:  utf8 usage with ENTITIES_XML_REQUIRED and UTF-8
72
This data contains special chars like &lt;, >, &amp; and &quot; as well as ä, ö, ß, à and ê
73
 
74
TEST:  basic usage with ENTITIES_HTML
75
This string contains &lt; &amp; &gt;.
76
 
77
TEST:  basic usage with ENTITIES_HTML and UTF-8
78
This string contains &lt; &amp; &gt;.
79
 
80
TEST:  utf8 usage with ENTITIES_HTML and UTF-8
81
This data contains special chars like &lt;, &gt;, &amp; and &quot; as well as &auml;, &ouml;, &szlig;, &agrave; and &ecirc;
82