diff options
Diffstat (limited to 'ext/spl/tests/arrayObject_exchangeArray_basic1.phpt')
-rw-r--r-- | ext/spl/tests/arrayObject_exchangeArray_basic1.phpt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt b/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt new file mode 100644 index 0000000..988f103 --- /dev/null +++ b/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt @@ -0,0 +1,40 @@ +--TEST-- +SPL: ArrayObject::exchangeArray() and copy-on-write references +--FILE-- +<?php +$ao = new ArrayObject(); +$swapIn = array(); +$cowRef = $swapIn; // create a copy-on-write ref to $swapIn +$ao->exchangeArray($swapIn); + +$ao['a'] = 'adding element to $ao'; +$swapIn['b'] = 'adding element to $swapIn'; +$ao['c'] = 'adding another element to $ao'; + +echo "\n--> swapIn: "; +var_dump($swapIn); + +echo "\n--> cowRef: "; +var_dump($cowRef); + +echo "\n--> ao: "; +var_dump($ao); +?> +--EXPECTF-- +--> swapIn: array(1) { + ["b"]=> + string(25) "adding element to $swapIn" +} + +--> cowRef: array(0) { +} + +--> ao: object(ArrayObject)#%d (1) { + ["storage":"ArrayObject":private]=> + array(2) { + ["a"]=> + string(21) "adding element to $ao" + ["c"]=> + string(29) "adding another element to $ao" + } +} |