Browse Source

Fixed failing tests with timezone independent equivalents

Chris Johnson 12 years ago
parent
commit
68eb4c5d8b

+ 0 - 4
tests/object_method_call.diff

@@ -1,4 +0,0 @@
-037+ Mon Sep 08 1975 09:00:00 GMT-0700 (PDT)
-037- Mon Sep 08 1975 09:00:00 GMT+0200 (EET)
-046+     string(6) "-07:00"
-046-     string(6) "+02:00"

+ 0 - 85
tests/object_method_call.exp

@@ -1,85 +0,0 @@
-array(2) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-}
-array(3) {
-  [0]=>
-  bool(true)
-  [1]=>
-  bool(false)
-  [2]=>
-  int(1234567890)
-}
-array(3) {
-  [0]=>
-  float(3.14)
-  [1]=>
-  int(42)
-  [2]=>
-  NULL
-}
-test4.js:1: TypeError: Testing::mytest() expects at least 2 parameters, 0 given
-array(4) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-  [2]=>
-  string(4) "arg3"
-  [3]=>
-  string(9) "extra_arg"
-}
-
-TEST: Javascript Date -> PHP DateTime
-======================================
-Mon Sep 08 1975 09:00:00 GMT+0200 (EET)
-array(2) {
-  [0]=>
-  object(DateTime)#4 (3) {
-    ["date"]=>
-    string(19) "1975-09-08 09:00:00"
-    ["timezone_type"]=>
-    int(1)
-    ["timezone"]=>
-    string(6) "+02:00"
-  }
-  [1]=>
-  string(3) "foo"
-}
-array(3) {
-  [0]=>
-  object(V8Object)#4 (2) {
-    ["mytest"]=>
-    object(V8Function)#6 (0) {
-    }
-    ["foo"]=>
-    string(8) "ORIGINAL"
-  }
-  [1]=>
-  array(3) {
-    [0]=>
-    int(1)
-    [1]=>
-    int(2)
-    [2]=>
-    int(3)
-  }
-  [2]=>
-  array(3) {
-    [0]=>
-    string(3) "foo"
-    [1]=>
-    string(3) "bar"
-    [2]=>
-    object(V8Object)#5 (2) {
-      ["mytest"]=>
-      object(V8Function)#6 (0) {
-      }
-      ["foo"]=>
-      string(8) "ORIGINAL"
-    }
-  }
-}
-===EOF===

+ 0 - 174
tests/object_method_call.log

@@ -1,174 +0,0 @@
-
----- EXPECTED OUTPUT
-array(2) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-}
-array(3) {
-  [0]=>
-  bool(true)
-  [1]=>
-  bool(false)
-  [2]=>
-  int(1234567890)
-}
-array(3) {
-  [0]=>
-  float(3.14)
-  [1]=>
-  int(42)
-  [2]=>
-  NULL
-}
-test4.js:1: TypeError: Testing::mytest() expects at least 2 parameters, 0 given
-array(4) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-  [2]=>
-  string(4) "arg3"
-  [3]=>
-  string(9) "extra_arg"
-}
-
-TEST: Javascript Date -> PHP DateTime
-======================================
-Mon Sep 08 1975 09:00:00 GMT+0200 (EET)
-array(2) {
-  [0]=>
-  object(DateTime)#4 (3) {
-    ["date"]=>
-    string(19) "1975-09-08 09:00:00"
-    ["timezone_type"]=>
-    int(1)
-    ["timezone"]=>
-    string(6) "+02:00"
-  }
-  [1]=>
-  string(3) "foo"
-}
-array(3) {
-  [0]=>
-  object(V8Object)#4 (2) {
-    ["mytest"]=>
-    object(V8Function)#6 (0) {
-    }
-    ["foo"]=>
-    string(8) "ORIGINAL"
-  }
-  [1]=>
-  array(3) {
-    [0]=>
-    int(1)
-    [1]=>
-    int(2)
-    [2]=>
-    int(3)
-  }
-  [2]=>
-  array(3) {
-    [0]=>
-    string(3) "foo"
-    [1]=>
-    string(3) "bar"
-    [2]=>
-    object(V8Object)#5 (2) {
-      ["mytest"]=>
-      object(V8Function)#6 (0) {
-      }
-      ["foo"]=>
-      string(8) "ORIGINAL"
-    }
-  }
-}
-===EOF===
----- ACTUAL OUTPUT
-array(2) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-}
-array(3) {
-  [0]=>
-  bool(true)
-  [1]=>
-  bool(false)
-  [2]=>
-  int(1234567890)
-}
-array(3) {
-  [0]=>
-  float(3.14)
-  [1]=>
-  int(42)
-  [2]=>
-  NULL
-}
-test4.js:1: TypeError: Testing::mytest() expects at least 2 parameters, 0 given
-array(4) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-  [2]=>
-  string(4) "arg3"
-  [3]=>
-  string(9) "extra_arg"
-}
-
-TEST: Javascript Date -> PHP DateTime
-======================================
-Mon Sep 08 1975 09:00:00 GMT-0700 (PDT)
-array(2) {
-  [0]=>
-  object(DateTime)#4 (3) {
-    ["date"]=>
-    string(19) "1975-09-08 09:00:00"
-    ["timezone_type"]=>
-    int(1)
-    ["timezone"]=>
-    string(6) "-07:00"
-  }
-  [1]=>
-  string(3) "foo"
-}
-array(3) {
-  [0]=>
-  object(V8Object)#4 (2) {
-    ["mytest"]=>
-    object(V8Function)#6 (0) {
-    }
-    ["foo"]=>
-    string(8) "ORIGINAL"
-  }
-  [1]=>
-  array(3) {
-    [0]=>
-    int(1)
-    [1]=>
-    int(2)
-    [2]=>
-    int(3)
-  }
-  [2]=>
-  array(3) {
-    [0]=>
-    string(3) "foo"
-    [1]=>
-    string(3) "bar"
-    [2]=>
-    object(V8Object)#5 (2) {
-      ["mytest"]=>
-      object(V8Function)#6 (0) {
-      }
-      ["foo"]=>
-      string(8) "ORIGINAL"
-    }
-  }
-}
-===EOF===
----- FAILED

+ 0 - 85
tests/object_method_call.out

@@ -1,85 +0,0 @@
-array(2) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-}
-array(3) {
-  [0]=>
-  bool(true)
-  [1]=>
-  bool(false)
-  [2]=>
-  int(1234567890)
-}
-array(3) {
-  [0]=>
-  float(3.14)
-  [1]=>
-  int(42)
-  [2]=>
-  NULL
-}
-test4.js:1: TypeError: Testing::mytest() expects at least 2 parameters, 0 given
-array(4) {
-  [0]=>
-  string(4) "arg1"
-  [1]=>
-  string(4) "arg2"
-  [2]=>
-  string(4) "arg3"
-  [3]=>
-  string(9) "extra_arg"
-}
-
-TEST: Javascript Date -> PHP DateTime
-======================================
-Mon Sep 08 1975 09:00:00 GMT-0700 (PDT)
-array(2) {
-  [0]=>
-  object(DateTime)#4 (3) {
-    ["date"]=>
-    string(19) "1975-09-08 09:00:00"
-    ["timezone_type"]=>
-    int(1)
-    ["timezone"]=>
-    string(6) "-07:00"
-  }
-  [1]=>
-  string(3) "foo"
-}
-array(3) {
-  [0]=>
-  object(V8Object)#4 (2) {
-    ["mytest"]=>
-    object(V8Function)#6 (0) {
-    }
-    ["foo"]=>
-    string(8) "ORIGINAL"
-  }
-  [1]=>
-  array(3) {
-    [0]=>
-    int(1)
-    [1]=>
-    int(2)
-    [2]=>
-    int(3)
-  }
-  [2]=>
-  array(3) {
-    [0]=>
-    string(3) "foo"
-    [1]=>
-    string(3) "bar"
-    [2]=>
-    object(V8Object)#5 (2) {
-      ["mytest"]=>
-      object(V8Function)#6 (0) {
-      }
-      ["foo"]=>
-      string(8) "ORIGINAL"
-    }
-  }
-}
-===EOF===

+ 0 - 53
tests/object_method_call.php

@@ -1,53 +0,0 @@
-<?php
-
-// Test class
-class Testing
-{
-	public $foo = 'ORIGINAL';
-	private $my_private = 'arf'; // Should not show in JS side
-	protected $my_protected = 'argh'; // Should not show in JS side
-
-	function mytest($a, $b, $c = NULL)
-	{
-		var_dump(func_get_args());
-	}
-}
-
-$a = new V8Js();
-$a->myobj = new Testing();
-
-$a->executeString("PHP.myobj.mytest('arg1', 'arg2');", "test1.js");
-$a->executeString("PHP.myobj.mytest(true, false, 1234567890);", "test2.js");
-$a->executeString("PHP.myobj.mytest(3.14, 42, null);", "test3.js");
-
-// Invalid parameters
-try {
-	$a->executeString("PHP.myobj.mytest();", "test4.js");
-} catch (V8JsException $e) {
-	echo $e->getMessage(), "\n";
-}
-
-try {
-	$a->executeString("PHP.myobj.mytest('arg1', 'arg2', 'arg3', 'extra_arg');", "test5.js");
-} catch (V8JsException $e) {
-	echo $e->getMessage(), "\n";
-}
-
-try {
-	date_default_timezone_set("UTC");
-	echo "\nTEST: Javascript Date -> PHP DateTime\n";
-	echo "======================================\n";
-	$a->executeString("date = new Date('September 8, 1975 09:00:00'); print(date + '\\n'); PHP.myobj.mytest(date, 'foo');", "test6.js");
-} catch (V8JsException $e) {
-	echo $e->getMessage(), "\n";
-}
-
-// Array / Object
-try {
-	$a->executeString("PHP.myobj.mytest(PHP.myobj, new Array(1,2,3), new Array('foo', 'bar', PHP.myobj));", "test7.js");
-} catch (V8JsException $e) {
-	var_dump($e);
-}
-
-?>
-===EOF===

+ 20 - 18
tests/object_method_call.phpt

@@ -2,6 +2,8 @@
 Test V8::executeString() : Calling methods of object passed from PHP
 --SKIPIF--
 <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--INI--
+date.timezone=UTC
 --FILE--
 <?php
 
@@ -16,6 +18,12 @@ class Testing
 	{
 		var_dump(func_get_args());
 	}
+
+  function mydatetest(DateTime $date, $b) {
+    $date->setTimeZone(new DateTimeZone(ini_get('date.timezone')));
+    echo $date->format(DateTime::RFC1123), "\n";
+    var_dump($b);
+  }
 }
 
 $a = new V8Js();
@@ -39,10 +47,9 @@ try {
 }
 
 try {
-	date_default_timezone_set("UTC");
 	echo "\nTEST: Javascript Date -> PHP DateTime\n";
 	echo "======================================\n";
-	$a->executeString("date = new Date('September 8, 1975 09:00:00'); print(date + '\\n'); PHP.myobj.mytest(date, 'foo');", "test6.js");
+	$a->executeString("date = new Date('September 8, 1975 09:00:00 GMT'); print(date.toUTCString() + '\\n'); PHP.myobj.mydatetest(date, 'foo');", "test6.js");
 } catch (V8JsException $e) {
 	echo $e->getMessage(), "\n";
 }
@@ -93,26 +100,18 @@ array(4) {
 
 TEST: Javascript Date -> PHP DateTime
 ======================================
-Mon Sep 08 1975 09:00:00 GMT+0200 (EET)
-array(2) {
-  [0]=>
-  object(DateTime)#4 (3) {
-    ["date"]=>
-    string(19) "1975-09-08 09:00:00"
-    ["timezone_type"]=>
-    int(1)
-    ["timezone"]=>
-    string(6) "+02:00"
-  }
-  [1]=>
-  string(3) "foo"
-}
+Mon, 08 Sep 1975 09:00:00 GMT
+Mon, 08 Sep 1975 09:00:00 +0000
+string(3) "foo"
 array(3) {
   [0]=>
-  object(V8Object)#4 (2) {
+  object(V8Object)#4 (3) {
     ["mytest"]=>
     object(V8Function)#6 (0) {
     }
+    ["mydatetest"]=>
+    object(V8Function)#7 (0) {
+    }
     ["foo"]=>
     string(8) "ORIGINAL"
   }
@@ -132,8 +131,11 @@ array(3) {
     [1]=>
     string(3) "bar"
     [2]=>
-    object(V8Object)#5 (2) {
+    object(V8Object)#5 (3) {
       ["mytest"]=>
+      object(V8Function)#7 (0) {
+      }
+      ["mydatetest"]=>
       object(V8Function)#6 (0) {
       }
       ["foo"]=>

+ 0 - 2
tests/return_value.diff

@@ -1,2 +0,0 @@
-035+   string(6) "-07:00"
-035-   string(6) "+02:00"

+ 0 - 42
tests/return_value.exp

@@ -1,42 +0,0 @@
-NULL
-object(V8Object)#3 (2) {
-  ["mytest"]=>
-  object(V8Function)#4 (0) {
-  }
-  ["foo"]=>
-  string(8) "ORIGINAL"
-}
-array(3) {
-  [0]=>
-  int(1)
-  [1]=>
-  int(2)
-  [2]=>
-  int(3)
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "1975-09-08 09:00:00"
-  ["timezone_type"]=>
-  int(1)
-  ["timezone"]=>
-  string(6) "+02:00"
-}
-int(1234567890)
-float(123.456789)
-string(11) "some string"
-bool(true)
-bool(false)
-===EOF===

+ 0 - 88
tests/return_value.log

@@ -1,88 +0,0 @@
-
----- EXPECTED OUTPUT
-NULL
-object(V8Object)#3 (2) {
-  ["mytest"]=>
-  object(V8Function)#4 (0) {
-  }
-  ["foo"]=>
-  string(8) "ORIGINAL"
-}
-array(3) {
-  [0]=>
-  int(1)
-  [1]=>
-  int(2)
-  [2]=>
-  int(3)
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "1975-09-08 09:00:00"
-  ["timezone_type"]=>
-  int(1)
-  ["timezone"]=>
-  string(6) "+02:00"
-}
-int(1234567890)
-float(123.456789)
-string(11) "some string"
-bool(true)
-bool(false)
-===EOF===
----- ACTUAL OUTPUT
-NULL
-object(V8Object)#3 (2) {
-  ["mytest"]=>
-  object(V8Function)#4 (0) {
-  }
-  ["foo"]=>
-  string(8) "ORIGINAL"
-}
-array(3) {
-  [0]=>
-  int(1)
-  [1]=>
-  int(2)
-  [2]=>
-  int(3)
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "1975-09-08 09:00:00"
-  ["timezone_type"]=>
-  int(1)
-  ["timezone"]=>
-  string(6) "-07:00"
-}
-int(1234567890)
-float(123.456789)
-string(11) "some string"
-bool(true)
-bool(false)
-===EOF===
----- FAILED

+ 0 - 42
tests/return_value.out

@@ -1,42 +0,0 @@
-NULL
-object(V8Object)#3 (2) {
-  ["mytest"]=>
-  object(V8Function)#4 (0) {
-  }
-  ["foo"]=>
-  string(8) "ORIGINAL"
-}
-array(3) {
-  [0]=>
-  int(1)
-  [1]=>
-  int(2)
-  [2]=>
-  int(3)
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-array(2) {
-  [0]=>
-  string(3) "foo"
-  [1]=>
-  string(3) "bar"
-}
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "1975-09-08 09:00:00"
-  ["timezone_type"]=>
-  int(1)
-  ["timezone"]=>
-  string(6) "-07:00"
-}
-int(1234567890)
-float(123.456789)
-string(11) "some string"
-bool(true)
-bool(false)
-===EOF===

+ 0 - 34
tests/return_value.php

@@ -1,34 +0,0 @@
-<?php
-
-$JS = <<< EOT
-function test(passed)
-{
-	return passed;
-}
-EOT;
-
-// Test class
-class Testing
-{
-	public $foo = 'ORIGINAL';
-	private $my_private = 'arf'; // Should not show in JS side
-	protected $my_protected = 'argh'; // Should not show in JS side
-
-	function mytest() { echo 'Here be monsters..', "\n"; }
-}
-
-$a = new V8Js();
-$a->myobj = new Testing();
-var_dump($a->executeString($JS, "test.js"));
-var_dump($a->executeString("test(PHP.myobj);", "test1.js"));
-var_dump($a->executeString("test(new Array(1,2,3));", "test2.js"));
-var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
-var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
-var_dump($a->executeString("test(new Date('September 8, 1975 09:00:00'));", "test4.js"));
-var_dump($a->executeString("test(1234567890);", "test5.js"));
-var_dump($a->executeString("test(123.456789);", "test6.js"));
-var_dump($a->executeString("test('some string');", "test7.js"));
-var_dump($a->executeString("test(true);", "test8.js"));
-var_dump($a->executeString("test(false);", "test9.js"));
-?>
-===EOF===

+ 6 - 9
tests/return_value.phpt

@@ -2,6 +2,8 @@
 Test V8::executeString() : Return values
 --SKIPIF--
 <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--INI--
+date.timezone=UTC
 --FILE--
 <?php
 
@@ -29,7 +31,9 @@ var_dump($a->executeString("test(PHP.myobj);", "test1.js"));
 var_dump($a->executeString("test(new Array(1,2,3));", "test2.js"));
 var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
 var_dump($a->executeString("test(new Array('foo', 'bar'));", "test3.js"));
-var_dump($a->executeString("test(new Date('September 8, 1975 09:00:00'));", "test4.js"));
+$date = $a->executeString("test(new Date('September 8, 1975 09:00:00 GMT'));", "test4.js");
+$date->setTimeZone(new DateTimeZone('GMT'));
+echo $date->format(DateTime::RFC1123), "\n";
 var_dump($a->executeString("test(1234567890);", "test5.js"));
 var_dump($a->executeString("test(123.456789);", "test6.js"));
 var_dump($a->executeString("test('some string');", "test7.js"));
@@ -66,14 +70,7 @@ array(2) {
   [1]=>
   string(3) "bar"
 }
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "1975-09-08 09:00:00"
-  ["timezone_type"]=>
-  int(1)
-  ["timezone"]=>
-  string(6) "+02:00"
-}
+Mon, 08 Sep 1975 09:00:00 +0000
 int(1234567890)
 float(123.456789)
 string(11) "some string"