return_value.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --TEST--
  2. Test V8::executeString() : Return values
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --INI--
  6. date.timezone=UTC
  7. --FILE--
  8. <?php
  9. $JS = <<< EOT
  10. function test(passed)
  11. {
  12. return passed;
  13. }
  14. EOT;
  15. // Test class
  16. class Testing
  17. {
  18. public $foo = 'ORIGINAL';
  19. private $my_private = 'arf'; // Should not show in JS side
  20. protected $my_protected = 'argh'; // Should not show in JS side
  21. function mytest() { echo 'Here be monsters..', "\n"; }
  22. }
  23. $a = new V8Js();
  24. $a->myobj = new Testing();
  25. var_dump($a->executeString($JS, "test.js"));
  26. var_dump($a->executeString("test(PHP.myobj);", "test1.js"));
  27. var_dump($a->executeString("test(new Array(1,2,3));", "test2.js"));
  28. var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
  29. var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
  30. $date = $a->executeString("test(new Date('September 8, 1975 09:00:00 GMT'));", "test4.js");
  31. $date->setTimeZone(new DateTimeZone('GMT'));
  32. echo $date->format(DateTime::RFC1123), "\n";
  33. var_dump($a->executeString("test(1234567890);", "test5.js"));
  34. var_dump($a->executeString("test(123.456789);", "test6.js"));
  35. var_dump($a->executeString("test('some string');", "test7.js"));
  36. var_dump($a->executeString("test(true);", "test8.js"));
  37. var_dump($a->executeString("test(false);", "test9.js"));
  38. ?>
  39. ===EOF===
  40. --EXPECTF--
  41. NULL
  42. object(Testing)#%d (3) {
  43. ["foo"]=>
  44. string(8) "ORIGINAL"
  45. ["my_private":"Testing":private]=>
  46. string(3) "arf"
  47. ["my_protected":protected]=>
  48. string(4) "argh"
  49. }
  50. array(3) {
  51. [0]=>
  52. int(1)
  53. [1]=>
  54. int(2)
  55. [2]=>
  56. int(3)
  57. }
  58. array(2) {
  59. [0]=>
  60. string(3) "foo"
  61. [1]=>
  62. string(3) "bar"
  63. }
  64. array(2) {
  65. [0]=>
  66. string(3) "foo"
  67. [1]=>
  68. string(3) "bar"
  69. }
  70. Mon, 08 Sep 1975 09:00:00 +0000
  71. int(1234567890)
  72. float(123.456789)
  73. string(11) "some string"
  74. bool(true)
  75. bool(false)
  76. ===EOF===