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::isValidName() 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::isValidName() basic tests=====' . PHP_EOL . PHP_EOL;
10
 
11
echo "TEST:  valid tag" . PHP_EOL;
12
$result = XML_Util::isValidName("alpha-x_y_z.123");
13
if (is_a($result, 'PEAR_Error')) {
14
    print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
15
} else {
16
    print "Valid XML name." . PHP_EOL . PHP_EOL;
17
}
18
 
19
echo "TEST:  invalid tag" . PHP_EOL;
20
$result = XML_Util::isValidName("invalidTag?");
21
if (is_a($result, 'PEAR_Error')) {
22
    print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
23
} else {
24
    print "Valid XML name." . PHP_EOL . PHP_EOL;
25
}
26
 
27
echo "TEST:  invalid tag that doesn't start with a letter" . PHP_EOL;
28
$result = XML_Util::isValidName("1234five");
29
if (is_a($result, 'PEAR_Error')) {
30
    print "Invalid XML name: " . $result->getMessage() . PHP_EOL . PHP_EOL;
31
} else {
32
    print "Valid XML name." . PHP_EOL . PHP_EOL;
33
}
34
 
35
?>
36
--EXPECT--
37
=====XML_Util::isValidName() basic tests=====
38
 
39
TEST:  valid tag
40
Valid XML name.
41
 
42
TEST:  invalid tag
43
Invalid XML name: XML names may only contain alphanumeric chars, period, hyphen, colon and underscores
44
 
45
TEST:  invalid tag that doesn't start with a letter
46
Invalid XML name: XML names may only start with letter or underscore