Skip to content

Commit 9f19055

Browse files
committed
Amend the test with more cases
1 parent 9499619 commit 9f19055

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ext/dom/tests/DOMElement_toggleAttribute.phpt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dom
88
$html = new DOMDocument();
99
$html->loadHTML('<!DOCTYPE HTML><html id="test"></html>');
1010
$xml = new DOMDocument();
11-
$xml->loadXML('<!DOCTYPE HTML><html id="test"></html>');
11+
$xml->loadXML('<?xml version="1.0"?><html id="test"></html>');
1212

1313
try {
1414
var_dump($html->documentElement->toggleAttribute("\0"));
@@ -58,11 +58,14 @@ var_dump($dom->documentElement->toggleAttribute('xmlns:anotherone'));
5858
echo $dom->saveXML();
5959
var_dump($dom->documentElement->toggleAttribute('xmlns:foo'));
6060
echo $dom->saveXML();
61+
var_dump($dom->documentElement->toggleAttribute('xmlns:nope', false));
62+
echo $dom->saveXML();
6163

6264
echo "Toggling namespaced attributes:\n";
6365
var_dump($dom->documentElement->toggleAttribute('test:test'));
6466
var_dump($dom->documentElement->firstElementChild->toggleAttribute('foo:test'));
6567
var_dump($dom->documentElement->firstElementChild->toggleAttribute('doesnotexist:test'));
68+
var_dump($dom->documentElement->firstElementChild->toggleAttribute('doesnotexist:test2', false));
6669
echo $dom->saveXML();
6770

6871
echo "namespace of test:test = ";
@@ -76,6 +79,8 @@ echo "Toggling namespaced attributes:\n";
7679
var_dump($dom->documentElement->toggleAttribute('test:test'));
7780
var_dump($dom->documentElement->firstElementChild->toggleAttribute('foo:test'));
7881
var_dump($dom->documentElement->firstElementChild->toggleAttribute('doesnotexist:test'));
82+
var_dump($dom->documentElement->firstElementChild->toggleAttribute('doesnotexist:test2', true));
83+
var_dump($dom->documentElement->firstElementChild->toggleAttribute('doesnotexist:test3', false));
7984
echo $dom->saveXML();
8085

8186
echo "Checking toggled namespace:\n";
@@ -100,19 +105,15 @@ bool(false)
100105
--- Selected attribute tests (XML) ---
101106
bool(false)
102107
<?xml version="1.0"?>
103-
<!DOCTYPE HTML>
104108
<html id="test"/>
105109
bool(true)
106110
<?xml version="1.0"?>
107-
<!DOCTYPE HTML>
108111
<html id="test" SELECTED=""/>
109112
bool(true)
110113
<?xml version="1.0"?>
111-
<!DOCTYPE HTML>
112114
<html id="test" SELECTED="" selected=""/>
113115
bool(false)
114116
<?xml version="1.0"?>
115-
<!DOCTYPE HTML>
116117
<html id="test" SELECTED=""/>
117118
--- id attribute tests ---
118119
bool(false)
@@ -132,10 +133,14 @@ bool(true)
132133
bool(false)
133134
<?xml version="1.0"?>
134135
<container xmlns="some:ns" xmlns:anotherone=""><foo:bar xmlns:foo="some:ns2"/><baz/></container>
136+
bool(false)
137+
<?xml version="1.0"?>
138+
<container xmlns="some:ns" xmlns:anotherone=""><foo:bar xmlns:foo="some:ns2"/><baz/></container>
135139
Toggling namespaced attributes:
136140
bool(true)
137141
bool(true)
138142
bool(true)
143+
bool(false)
139144
<?xml version="1.0"?>
140145
<container xmlns="some:ns" xmlns:anotherone="" test:test=""><foo:bar xmlns:foo="some:ns2" foo:test="" doesnotexist:test=""/><baz/></container>
141146
namespace of test:test = NULL
@@ -145,7 +150,9 @@ Toggling namespaced attributes:
145150
bool(false)
146151
bool(false)
147152
bool(false)
153+
bool(true)
154+
bool(false)
148155
<?xml version="1.0"?>
149-
<container xmlns="some:ns" xmlns:anotherone=""><foo:bar xmlns:foo="some:ns2"/><baz/></container>
156+
<container xmlns="some:ns" xmlns:anotherone=""><foo:bar xmlns:foo="some:ns2" doesnotexist:test2=""/><baz/></container>
150157
Checking toggled namespace:
151158
string(0) ""

0 commit comments

Comments
 (0)