0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 08:11:52 +00:00

Add test on visibility of properties on enumeration

This commit is contained in:
Stefan Siegl 2014-04-11 19:04:05 +02:00
parent 8f200b3905
commit aa924a8cb3

View File

@ -0,0 +1,56 @@
--TEST--
Test V8::executeString() : Property visibility - enumerate
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
class Foo {
private $privBar = "privBar";
protected $protBar = "protBar";
public $pubBar = "pubBar";
public function dump() {
foreach($this as $key => $value) {
echo("$key => ");
var_dump($value);
}
}
}
$js = new V8Js();
$js->foo = new Foo();
$script = <<<END
for(var key in PHP.foo) {
if(PHP.foo.hasOwnProperty(key)) {
var_dump(key);
if(key[0] === '$') {
var_dump(PHP.foo[key]);
}
else {
var_dump("function");
}
}
}
END;
$js->executeString($script);
echo "--- PHP ---\n";
$js->foo->dump();
?>
===EOF===
--EXPECT--
string(4) "dump"
string(8) "function"
string(7) "$pubBar"
string(6) "pubBar"
--- PHP ---
privBar => string(7) "privBar"
protBar => string(7) "protBar"
pubBar => string(6) "pubBar"
===EOF===