diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
commit | 993e1866df547532a05ab6db76c9ff5aefc9a3df (patch) | |
tree | 169d3bde0974235d3cde164786ef6f381a4749a7 /ext/standard/tests/serialize/serialization_arrays_001.phpt | |
parent | 1f589a2bd44ba835ad1b009a5d83abd453724829 (diff) | |
download | php-993e1866df547532a05ab6db76c9ff5aefc9a3df.tar.gz |
Imported Upstream version 5.2.6upstream/5.2.6
Diffstat (limited to 'ext/standard/tests/serialize/serialization_arrays_001.phpt')
-rw-r--r-- | ext/standard/tests/serialize/serialization_arrays_001.phpt | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/ext/standard/tests/serialize/serialization_arrays_001.phpt b/ext/standard/tests/serialize/serialization_arrays_001.phpt new file mode 100644 index 000000000..e39954277 --- /dev/null +++ b/ext/standard/tests/serialize/serialization_arrays_001.phpt @@ -0,0 +1,108 @@ +--TEST-- +Test serialize() & unserialize() functions: arrays (circular references) +--FILE-- +<?php +/* Prototype : proto string serialize(mixed variable) + * Description: Returns a string representation of variable (which can later be unserialized) + * Source code: ext/standard/var.c + * Alias to functions: + */ +/* Prototype : proto mixed unserialize(string variable_representation) + * Description: Takes a string representation of variable and recreates it + * Source code: ext/standard/var.c + * Alias to functions: + */ + +echo "\n--- Testing Circular reference of an array ---\n"; + +echo "-- Normal array --\n"; +$arr_circ = array(0, 1, -2, 3.333333, "a", array(), &$arr_circ); +$serialize_data = serialize($arr_circ); +$arr_circ[6] = null; +var_dump( $serialize_data ); +$arr_circ = unserialize($serialize_data); +var_dump( $arr_circ ); +$arr_circ[6] = null; + +echo "\n-- Associative array --\n"; +$arr_asso = array("a" => "test"); +$arr_asso[ "b" ] = &$arr_asso[ "a" ]; +var_dump($arr_asso); +$serialize_data = serialize($arr_asso); +var_dump($serialize_data); +$arr_asso = unserialize($serialize_data); +var_dump($arr_asso); + +echo "\nDone"; +?> +--EXPECTF-- + +--- Testing Circular reference of an array --- +-- Normal array -- +string(238) "a:7:{i:0;i:0;i:1;i:1;i:2;i:-2;i:3;d:3.333333000000000101437080957111902534961700439453125;i:4;s:1:"a";i:5;a:0:{}i:6;a:7:{i:0;i:0;i:1;i:1;i:2;i:-2;i:3;d:3.333333000000000101437080957111902534961700439453125;i:4;s:1:"a";i:5;a:0:{}i:6;R:8;}}" +array(7) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(-2) + [3]=> + float(3.333333) + [4]=> + string(1) "a" + [5]=> + array(0) { + } + [6]=> + &array(7) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(-2) + [3]=> + float(3.333333) + [4]=> + string(1) "a" + [5]=> + array(0) { + } + [6]=> + &array(7) { + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(-2) + [3]=> + float(3.333333) + [4]=> + string(1) "a" + [5]=> + array(0) { + } + [6]=> + *RECURSION* + } + } +} + +-- Associative array -- +array(2) { + ["a"]=> + &string(4) "test" + ["b"]=> + &string(4) "test" +} +string(37) "a:2:{s:1:"a";s:4:"test";s:1:"b";R:2;}" +array(2) { + ["a"]=> + &string(4) "test" + ["b"]=> + &string(4) "test" +} + +Done |