php_exceptions_006.phpt 850 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test V8::executeString() : PHP Exception handling (JS throws normal PHP-object)
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. class Foo {
  8. function getNonExceptionObject() {
  9. return new \Foo();
  10. }
  11. }
  12. $v8 = new V8Js();
  13. $v8->foo = new \Foo();
  14. $JS = <<< EOT
  15. var ex = PHP.foo.getNonExceptionObject();
  16. print("after getNonExceptionObject\\n");
  17. throw ex;
  18. print("after throw\\n");
  19. EOT;
  20. try {
  21. $v8->executeString($JS, 'php_exceptions_006');
  22. }
  23. catch(V8JsScriptException $e) {
  24. echo "Got V8JsScriptException\n";
  25. var_dump($e->getMessage());
  26. // previous exception should be NULL, as it is *not* a php exception
  27. var_dump($e->getPrevious());
  28. }
  29. ?>
  30. ===EOF===
  31. --EXPECTF--
  32. after getNonExceptionObject
  33. Got V8JsScriptException
  34. string(34) "php_exceptions_006:3: [object Foo]"
  35. NULL
  36. ===EOF===