forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDOMDocument_strictErrorChecking_variation.phpt
59 lines (50 loc) · 1.51 KB
/
DOMDocument_strictErrorChecking_variation.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
51
52
53
54
55
56
57
58
59
--TEST--
DomDocument::$strictErrorChecking - ensure turning off actually works
--CREDITS--
Vincent Tsao <notes4vincent@gmail.com>
(and Dan Convissor)
# TestFest 2009 NYPHP
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
echo "Load document\n";
$doc = new DOMDocument;
$doc->load(dirname(__FILE__)."/book.xml");
echo "See if strictErrorChecking is on\n";
var_dump($doc->strictErrorChecking);
echo "Should throw DOMException when strictErrorChecking is on\n";
try {
$attr = $doc->createAttribute(0);
} catch (DOMException $e) {
echo "GOOD. DOMException thrown\n";
echo $e->getMessage() ."\n";
} catch (Exception $e) {
echo "OOPS. Other exception thrown\n";
}
echo "Turn strictErrorChecking off\n";
$doc->strictErrorChecking = false;
echo "See if strictErrorChecking is off\n";
var_dump($doc->strictErrorChecking);
echo "Should raise PHP error because strictErrorChecking is off\n";
try {
$attr = $doc->createAttribute(0);
} catch (DOMException $e) {
echo "OOPS. DOMException thrown\n";
echo $e->getMessage() ."\n";
} catch (Exception $e) {
echo "OOPS. Other exception thrown\n";
}
?>
--EXPECTF--
Load document
See if strictErrorChecking is on
bool(true)
Should throw DOMException when strictErrorChecking is on
GOOD. DOMException thrown
Invalid Character Error
Turn strictErrorChecking off
See if strictErrorChecking is off
bool(false)
Should raise PHP error because strictErrorChecking is off
Warning: DOMDocument::createAttribute(): Invalid Character Error in %sDOMDocument_strictErrorChecking_variation.php on line %d