/
testBasic_isValidName.phpt
50 lines (40 loc) · 1.39 KB
/
testBasic_isValidName.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
--TEST--
XML_Util2::isValidName() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
$util = new XML_Util2();
echo '=====XML_Util2::isValidName() basic tests=====' . PHP_EOL . PHP_EOL;
echo "TEST: valid tag" . PHP_EOL;
try {
$result = $util->isValidName("alpha-x_y_z.123");
print "Valid XML name." . PHP_EOL . PHP_EOL;
} catch (XML_Util2_Exception $e) {
print "Invalid XML name: " . $e->getMessage() . PHP_EOL . PHP_EOL;
}
echo "TEST: invalid tag" . PHP_EOL;
try {
$result = $util->isValidName("invalidTag?");
print "Valid XML name." . PHP_EOL . PHP_EOL;
} catch (XML_Util2_Exception $e) {
print "Invalid XML name: " . $e->getMessage() . PHP_EOL . PHP_EOL;
}
echo "TEST: invalid tag that doesn't start with a letter" . PHP_EOL;
try {
$result = $util->isValidName("1234five");
print "Valid XML name." . PHP_EOL . PHP_EOL;
} catch (XML_Util2_Exception $e) {
print "Invalid XML name: " . $e->getMessage() . PHP_EOL . PHP_EOL;
}
?>
--EXPECT--
=====XML_Util2::isValidName() basic tests=====
TEST: valid tag
Valid XML name.
TEST: invalid tag
Invalid XML name: XML names may only contain alphanumeric chars, period, hyphen, colon and underscores
TEST: invalid tag that doesn't start with a letter
Invalid XML name: XML names may only start with letter or underscore