diff options
author | Stanislav Malyshev <stas@php.net> | 2013-06-23 13:54:50 -0700 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2013-06-23 13:54:50 -0700 |
commit | 7272e3e72232b4aa0374209b7779df440c9bdc33 (patch) | |
tree | 4b93c59f73701d8ad2a9be2d58fccd30b3532276 /tests | |
parent | 296a12efbbdcb4db4a28b5744e3f3bd60e8fec9f (diff) | |
parent | f1e37d03c117317f543d9ff68ea8e3e23da077bd (diff) | |
download | php-git-7272e3e72232b4aa0374209b7779df440c9bdc33.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
Adding test to verify that __sleep can handle parent classes' private members
Adding test to stabelize keys used when converting objects to arrays
Diffstat (limited to 'tests')
-rw-r--r-- | tests/classes/array_conversion_keys.phpt | 18 | ||||
-rw-r--r-- | tests/classes/private_members_serialization.phpt | 23 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/classes/array_conversion_keys.phpt b/tests/classes/array_conversion_keys.phpt new file mode 100644 index 0000000000..e3bd7e0331 --- /dev/null +++ b/tests/classes/array_conversion_keys.phpt @@ -0,0 +1,18 @@ +--TEST-- +Verifies the correct conversion of objects to arrays +--FILE-- +<?php +class foo +{ + private $private = 'private'; + protected $protected = 'protected'; + public $public = 'public'; +} +var_export((array) new foo); +?> +--EXPECTF-- +array ( + '' . "\0" . 'foo' . "\0" . 'private' => 'private', + '' . "\0" . '*' . "\0" . 'protected' => 'protected', + 'public' => 'public', +) diff --git a/tests/classes/private_members_serialization.phpt b/tests/classes/private_members_serialization.phpt new file mode 100644 index 0000000000..c8dd3ab248 --- /dev/null +++ b/tests/classes/private_members_serialization.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verifies that it is possible to return private member names of parent classes in __sleep +--FILE-- +<?php +class foo +{ + private $private = 'private'; + protected $protected = 'protected'; + public $public = 'public'; +} + +class bar extends foo +{ + public function __sleep() + { + return array("\0foo\0private", 'protected', 'public'); + } +} + +var_dump(str_replace("\0", '\0', serialize(new bar()))); +?> +--EXPECTF-- +string(114) "O:3:"bar":3:{s:12:"\0foo\0private";s:7:"private";s:12:"\0*\0protected";s:9:"protected";s:6:"public";s:6:"public";}" |