Skip to content

Commit 0adefa5

Browse files
committed
Add a test for issue 25 (native properties)
1 parent 44c329b commit 0adefa5

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/object_dom.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Test V8::executeString() : DOM object passed from PHP
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$JS = <<< EOT
9+
print('js1: ', PHP.test.length, "\\n");
10+
var elements = PHP.dom.getElementsByTagName('node');
11+
print('js2: ', elements.length, "\\n");
12+
var node = elements.item(0);
13+
print("hasChildNodes: "); var_dump(node.hasChildNodes());
14+
print("hasAttribute('class'): "); var_dump(node.hasAttribute('class'));
15+
//var_dump(node);
16+
EOT;
17+
18+
$dom = new DomDocument();
19+
$dom->loadXML('<node class="test"/>');
20+
21+
$elements = $dom->getElementsByTagName('node');
22+
echo 'php: ', $elements->length, "\n";
23+
$node = $elements->item(0);
24+
echo "hasChildNodes: "; var_dump($node->hasChildNodes());
25+
echo "hasAttribute('class'): "; var_dump($node->hasAttribute('class'));
26+
//var_dump($node);
27+
28+
$a = new V8Js();
29+
$a->dom = $dom;
30+
$a->test = array( 'length' => 1 );
31+
$a->executeString($JS, "test.js");
32+
33+
?>
34+
===EOF===
35+
--EXPECT--
36+
php: 1
37+
hasChildNodes: bool(false)
38+
hasAttribute('class'): bool(true)
39+
js1: 1
40+
js2: 1
41+
hasChildNodes: bool(false)
42+
hasAttribute('class'): bool(true)
43+
===EOF===

0 commit comments

Comments
 (0)