1--TEST--
2DomDocument::$strictErrorChecking - ensure turning off actually works
3--CREDITS--
4Vincent Tsao <notes4vincent@gmail.com>
5(and Dan Convissor)
6# TestFest 2009 NYPHP
7--EXTENSIONS--
8dom
9--FILE--
10<?php
11
12echo "Load document\n";
13$doc = new DOMDocument;
14$doc->load(__DIR__."/book.xml");
15
16echo "See if strictErrorChecking is on\n";
17var_dump($doc->strictErrorChecking);
18
19echo "Should throw DOMException when strictErrorChecking is on\n";
20try {
21    $attr = $doc->createAttribute(0);
22} catch (DOMException $e) {
23    echo "GOOD. DOMException thrown\n";
24    echo $e->getMessage() ."\n";
25} catch (Exception $e) {
26    echo "OOPS. Other exception thrown\n";
27}
28
29
30echo "Turn strictErrorChecking off\n";
31$doc->strictErrorChecking = false;
32
33echo "See if strictErrorChecking is off\n";
34var_dump($doc->strictErrorChecking);
35
36echo "Should raise PHP error because strictErrorChecking is off\n";
37try {
38    $attr = $doc->createAttribute(0);
39} catch (DOMException $e) {
40    echo "OOPS. DOMException thrown\n";
41    echo $e->getMessage() ."\n";
42} catch (Exception $e) {
43    echo "OOPS. Other exception thrown\n";
44}
45
46?>
47--EXPECTF--
48Load document
49See if strictErrorChecking is on
50bool(true)
51Should throw DOMException when strictErrorChecking is on
52GOOD. DOMException thrown
53Invalid Character Error
54Turn strictErrorChecking off
55See if strictErrorChecking is off
56bool(false)
57Should raise PHP error because strictErrorChecking is off
58
59Warning: DOMDocument::createAttribute(): Invalid Character Error in %s on line %d
60