diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/spl/tests/SplObjectStorage_getHash.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/spl/tests/SplObjectStorage_getHash.phpt')
-rw-r--r-- | ext/spl/tests/SplObjectStorage_getHash.phpt | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/ext/spl/tests/SplObjectStorage_getHash.phpt b/ext/spl/tests/SplObjectStorage_getHash.phpt new file mode 100644 index 0000000..f309b3d --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_getHash.phpt @@ -0,0 +1,60 @@ +--TEST-- +SplObjectStorage::getHash implementation +--FILE-- +<?php +$s = new SplObjectStorage(); +$o1 = new Stdclass; +$o2 = new Stdclass; +$s[$o1] = "some_value\n"; +echo $s->offsetGet($o1); + +class MySplObjectStorage extends SplObjectStorage { + public function getHash($obj) { + return 2; + } +} + +try { + $s1 = new MySplObjectStorage; + $s1[$o1] = "foo"; +} catch(Exception $e) { + echo "caught\n"; +} + +class MySplObjectStorage2 extends SplObjectStorage { + public function getHash($obj) { + throw new Exception("foo"); + return "asd"; + } +} + +try { + $s2 = new MySplObjectStorage2; + $s2[$o2] = "foo"; +} catch(Exception $e) { + echo "caught\n"; +} + +class MySplObjectStorage3 extends SplObjectStorage { + public function getHash($obj) { + return "asd"; + } +} + +$s3 = new MySplObjectStorage3; +$s3[$o1] = $o1; +var_dump($s3[$o1]); +$s3[$o2] = $o2; + +var_dump($s3[$o1] === $s3[$o2]); + +?> +===DONE=== +--EXPECT-- +some_value +caught +caught +object(stdClass)#2 (0) { +} +bool(true) +===DONE=== |