0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 12:51:52 +00:00
phpv8/tests/property_visibility-delete.phpt
Stefan Siegl 48feb0bf35 Don't unset non-public properties, just hide them.
Before non-public properties were not reset also, trying to
unset them just caused a fatal php error, effectively crashing
the whole script.
2014-04-11 20:42:55 +02:00

76 lines
1.1 KiB
PHP

--TEST--
Test V8::executeString() : Property visibility - delete
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
class Foo {
private $privBar = "privBar";
protected $protBar = "protBar";
public $pubBar = "pubBar";
public function dump($a)
{
var_dump(@$this->$a);
}
}
$js = new V8Js();
$js->foo = new Foo();
$script = <<<END
var_dump(PHP.foo.privBar);
delete PHP.foo.privBar;
var_dump(PHP.foo.privBar);
PHP.foo.privBar = 42;
var_dump(PHP.foo.privBar);
delete PHP.foo.privBar;
var_dump(PHP.foo.privBar);
var_dump(PHP.foo.protBar);
delete PHP.foo.protBar;
var_dump(PHP.foo.protBar);
var_dump(PHP.foo.pubBar);
delete PHP.foo.pubBar;
var_dump(PHP.foo.pubBar);
END;
$js->foo->dump('privBar');
$js->foo->dump('protBar');
$js->foo->dump('pubBar');
echo "--- JS ---\n";
$js->executeString($script);
echo "--- PHP ---\n";
$js->foo->dump('privBar');
$js->foo->dump('protBar');
$js->foo->dump('pubBar');
?>
===EOF===
--EXPECT--
string(7) "privBar"
string(7) "protBar"
string(6) "pubBar"
--- JS ---
NULL
NULL
int(42)
NULL
NULL
NULL
string(6) "pubBar"
NULL
--- PHP ---
string(7) "privBar"
string(7) "protBar"
NULL
===EOF===