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

Add test on property visibility regarding hasOwnProperty

This commit is contained in:
Stefan Siegl 2014-04-11 20:50:36 +02:00
parent 48feb0bf35
commit 956eacb180

View File

@ -0,0 +1,49 @@
--TEST--
Test V8::executeString() : Property visibility - has property
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
class Foo {
private $privBar = "privBar";
protected $protBar = "protBar";
public $pubBar = "pubBar";
}
$js = new V8Js();
$js->foo = new Foo();
$script = <<<END
var_dump(PHP.foo.hasOwnProperty("privBar"));
var_dump(PHP.foo.hasOwnProperty("protBar"));
var_dump(PHP.foo.hasOwnProperty("pubBar"));
var_dump(PHP.foo.hasOwnProperty("unknownBar"));
PHP.foo.privBar = 23;
PHP.foo.protBar = 23;
PHP.foo.pubBar = 23;
PHP.foo.unknownBar = 23;
var_dump(PHP.foo.hasOwnProperty("privBar"));
var_dump(PHP.foo.hasOwnProperty("protBar"));
var_dump(PHP.foo.hasOwnProperty("pubBar"));
var_dump(PHP.foo.hasOwnProperty("unknownBar"));
END;
$js->executeString($script);
?>
===EOF===
--EXPECT--
bool(false)
bool(false)
bool(true)
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
===EOF===