X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fserialize%2Fserializable.phpt;h=5f6622784aab399d6f77a90d87361d43b3cf4257;hb=ab79bbfb1d04ffb6c82d3489ca585fac65d7c778;hp=337537ca487944c72a2043fccf93d6ed0c9f77eb;hpb=1f8a3c11e744bbbb2cd7bc304d1c33b2036d013f;p=awesomized%2Fext-ion diff --git a/tests/serialize/serializable.phpt b/tests/serialize/serializable.phpt index 337537c..5f66227 100644 --- a/tests/serialize/serializable.phpt +++ b/tests/serialize/serializable.phpt @@ -38,6 +38,18 @@ class recursive implements Serializable { } } +class except implements Serializable { + function __construct (public $onserialize = false) {} + function serialize() : string { + if ($this->onserialize) + throw new Exception("except on serialize"); + return "<>"; + } + function unserialize(string $data) : void { + throw new Exception("except on unserialize"); + } +} + echo "\n"; $t = new test; @@ -50,6 +62,17 @@ var_dump($tree); $s = ion\serialize($tree); echo $s,"\n"; debug_zval_dump(ion\unserialize($s)); + +try { + ion\serialize(new except(true)); +} catch (Exception $e) { + printf("caught %s: %s\n", get_class($e), $e->getMessage()); +} +try { + ion\unserialize(ion\serialize(new except())); +} catch (Exception $e) { + printf("caught %s: %s\n", get_class($e), $e->getMessage()); +} ?> DONE --EXPECTF-- @@ -59,7 +82,9 @@ Deprecated: test implements the Serializable interface, which is deprecated. Imp Deprecated: recursive implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %sserialize/serializable.php on line %d -PHP::[S::test::"foobar",r::1] +Deprecated: except implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %sserialize/serializable.php on line %d + +[S::test::{{"foobar"}},r::1] array(2) refcount(2){ [0]=> object(test)#%d (1) refcount(2){ @@ -83,16 +108,18 @@ object(recursive)#%d (2) { NULL } } -PHP::S::recursive::"node:S::recursive::\"leaf\"" +S::recursive::{{"node:S::recursive::{{\"leaf\"}}"}} object(recursive)#%d (2) refcount(1){ ["id":"recursive":private]=> string(4) "node" refcount(1) ["r":protected]=> - object(recursive)#10 (2) refcount(1){ + object(recursive)#%d (2) refcount(1){ ["id":"recursive":private]=> string(4) "leaf" refcount(1) ["r":protected]=> NULL } } +caught Exception: except on serialize +caught Exception: except on unserialize DONE