0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-19 00:25:18 +00:00

Add a test for issue 25 (native properties)

This commit is contained in:
C. Scott Ananian 2013-10-07 22:12:20 -04:00
parent 44c329b953
commit 0adefa5048

43
tests/object_dom.phpt Normal file
View File

@ -0,0 +1,43 @@
--TEST--
Test V8::executeString() : DOM object passed from PHP
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$JS = <<< EOT
print('js1: ', PHP.test.length, "\\n");
var elements = PHP.dom.getElementsByTagName('node');
print('js2: ', elements.length, "\\n");
var node = elements.item(0);
print("hasChildNodes: "); var_dump(node.hasChildNodes());
print("hasAttribute('class'): "); var_dump(node.hasAttribute('class'));
//var_dump(node);
EOT;
$dom = new DomDocument();
$dom->loadXML('<node class="test"/>');
$elements = $dom->getElementsByTagName('node');
echo 'php: ', $elements->length, "\n";
$node = $elements->item(0);
echo "hasChildNodes: "; var_dump($node->hasChildNodes());
echo "hasAttribute('class'): "; var_dump($node->hasAttribute('class'));
//var_dump($node);
$a = new V8Js();
$a->dom = $dom;
$a->test = array( 'length' => 1 );
$a->executeString($JS, "test.js");
?>
===EOF===
--EXPECT--
php: 1
hasChildNodes: bool(false)
hasAttribute('class'): bool(true)
js1: 1
js2: 1
hasChildNodes: bool(false)
hasAttribute('class'): bool(true)
===EOF===