DateTimeZone_clone_basic2.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --TEST--
  2. Testing clone on objects whose class derived from DateTimeZone class
  3. --FILE--
  4. <?php
  5. //Set the default time zone
  6. date_default_timezone_set("Europe/London");
  7. class DateTimeZoneExt1 extends DateTimeZone {
  8. public $property1 = 99;
  9. public $property2 = "Hello";
  10. }
  11. class DateTimeZoneExt2 extends DateTimeZoneExt1 {
  12. public $property3 = true;
  13. public $property4 = 10.5;
  14. }
  15. echo "*** Testing clone on objects whose class derived from DateTimeZone class ***\n";
  16. $d1 = new DateTimeZoneExt1("Europe/London");
  17. var_dump($d1);
  18. $d1_clone = clone $d1;
  19. var_dump($d1_clone);
  20. $d2 = new DateTimeZoneExt2("Europe/London");
  21. var_dump($d2);
  22. $d2_clone = clone $d2;
  23. var_dump($d2_clone);
  24. ?>
  25. --EXPECTF--
  26. *** Testing clone on objects whose class derived from DateTimeZone class ***
  27. object(DateTimeZoneExt1)#%d (4) {
  28. ["property1"]=>
  29. int(99)
  30. ["property2"]=>
  31. string(5) "Hello"
  32. ["timezone_type"]=>
  33. int(3)
  34. ["timezone"]=>
  35. string(13) "Europe/London"
  36. }
  37. object(DateTimeZoneExt1)#%d (4) {
  38. ["property1"]=>
  39. int(99)
  40. ["property2"]=>
  41. string(5) "Hello"
  42. ["timezone_type"]=>
  43. int(3)
  44. ["timezone"]=>
  45. string(13) "Europe/London"
  46. }
  47. object(DateTimeZoneExt2)#%d (6) {
  48. ["property1"]=>
  49. int(99)
  50. ["property2"]=>
  51. string(5) "Hello"
  52. ["property3"]=>
  53. bool(true)
  54. ["property4"]=>
  55. float(10.5)
  56. ["timezone_type"]=>
  57. int(3)
  58. ["timezone"]=>
  59. string(13) "Europe/London"
  60. }
  61. object(DateTimeZoneExt2)#%d (6) {
  62. ["property1"]=>
  63. int(99)
  64. ["property2"]=>
  65. string(5) "Hello"
  66. ["property3"]=>
  67. bool(true)
  68. ["property4"]=>
  69. float(10.5)
  70. ["timezone_type"]=>
  71. int(3)
  72. ["timezone"]=>
  73. string(13) "Europe/London"
  74. }