serialize_002.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Test serialize(V8Function) : __sleep and __wakeup throw
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. $v8 = new V8Js();
  8. $obj = $v8->executeString('(function() { })');
  9. var_dump($obj);
  10. try {
  11. $stored = serialize($obj);
  12. }
  13. catch(\V8JsException $e) {
  14. var_dump(get_class($e));
  15. var_dump($e->getMessage());
  16. }
  17. $stored = 'O:10:"V8Function":0:{}';
  18. try {
  19. $obj2 = unserialize($stored);
  20. }
  21. catch(\V8JsException $e) {
  22. var_dump(get_class($e));
  23. var_dump($e->getMessage());
  24. }
  25. var_dump(isset($obj2));
  26. $stored = 'O:10:"V8Function":1:{s:3:"foo";i:23;}';
  27. try {
  28. $obj = unserialize($stored);
  29. }
  30. catch(\V8JsException $e) {
  31. var_dump(get_class($e));
  32. var_dump($e->getMessage());
  33. }
  34. var_dump(isset($obj3));
  35. ?>
  36. ===EOF===
  37. --EXPECT--
  38. object(V8Function)#2 (0) {
  39. }
  40. string(13) "V8JsException"
  41. string(56) "You cannot serialize or unserialize V8Function instances"
  42. string(13) "V8JsException"
  43. string(56) "You cannot serialize or unserialize V8Function instances"
  44. bool(false)
  45. string(13) "V8JsException"
  46. string(56) "You cannot serialize or unserialize V8Function instances"
  47. bool(false)
  48. ===EOF===