summaryrefslogtreecommitdiff
path: root/tests/classes/clone_004.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /tests/classes/clone_004.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'tests/classes/clone_004.phpt')
-rw-r--r--tests/classes/clone_004.phpt82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/classes/clone_004.phpt b/tests/classes/clone_004.phpt
new file mode 100644
index 0000000..2059103
--- /dev/null
+++ b/tests/classes/clone_004.phpt
@@ -0,0 +1,82 @@
+--TEST--
+ZE2 object cloning, 4
+--FILE--
+<?php
+abstract class base {
+ public $a = 'base';
+
+ // disallow cloning
+ private function __clone() {}
+}
+
+class test extends base {
+ public $b = 'test';
+
+ // reenable cloning
+ public function __clone() {}
+
+ public function show() {
+ var_dump($this);
+ }
+}
+
+echo "Original\n";
+$o1 = new test;
+$o1->a = array(1,2);
+$o1->b = array(3,4);
+$o1->show();
+
+echo "Clone\n";
+$o2 = clone $o1;
+$o2->show();
+
+echo "Modify\n";
+$o2->a = 5;
+$o2->b = 6;
+$o2->show();
+
+echo "Done\n";
+?>
+--EXPECT--
+Original
+object(test)#1 (2) {
+ ["b"]=>
+ array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ }
+ ["a"]=>
+ array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ }
+}
+Clone
+object(test)#2 (2) {
+ ["b"]=>
+ array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ }
+ ["a"]=>
+ array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ }
+}
+Modify
+object(test)#2 (2) {
+ ["b"]=>
+ int(6)
+ ["a"]=>
+ int(5)
+}
+Done