Browse Source

Added tests/tojson_001.phpt

Christiano Becker 2 years ago
parent
commit
9cb0400f90
1 changed files with 20 additions and 0 deletions
  1. 20 0
      tests/tojson_001.phpt

+ 20 - 0
tests/tojson_001.phpt

@@ -0,0 +1,20 @@
+--TEST--
+Test V8::executeString() : redirects toJSON() to jsonSerialize
+--SKIPIF--
+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--FILE--
+<?php
+class Foo implements JsonSerializable {
+    public function jsonSerialize(): mixed {
+    	return ['foo', 'bar'];
+    }
+}
+
+$v8 = new V8Js;
+$v8->foo = new Foo;
+$v8->executeString('var_dump(JSON.stringify(PHP.foo));');
+?>
+===EOF===
+--EXPECTF--
+string(13) "["foo","bar"]"
+===EOF===