From: William Martin Date: Fri, 29 Jan 2010 15:43:39 +0000 (+0000) Subject: Backport some SplObjectStorage tests to 5.2 X-Git-Tag: php-5.2.13RC2~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=62567b90b3a258e9e69bf3c142ca1c5d4d7e8e91;p=php Backport some SplObjectStorage tests to 5.2 --- diff --git a/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt new file mode 100644 index 0000000000..ebf7a2fe58 --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt @@ -0,0 +1,22 @@ +--TEST-- +Check that SplObjectStorage::attach generates a warning and returns NULL when bad params are passed +--CREDITS-- +PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com) +--SKIPIF-- + +--FILE-- +attach(true)); +var_dump($s->attach(new stdClass, true, true)); + +?> +--EXPECTF-- +Warning: SplObjectStorage::attach() expects parameter 1 to be object, boolean given in %s on line %d +NULL + +Warning: SplObjectStorage::attach() expects exactly 1 parameter, 3 given in %s on line %d +NULL + diff --git a/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt new file mode 100644 index 0000000000..0e96cd83be --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt @@ -0,0 +1,45 @@ +--TEST-- +Check that SplObjectStorage::contains generate a warning and returns NULL when passed non-object param +--CREDITS-- +PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com) +--SKIPIF-- + +--FILE-- +contains($input)); +} + +?> +--EXPECTF-- +Warning: SplObjectStorage::contains() expects parameter 1 to be object, array given in %s on line %d +NULL + +Warning: SplObjectStorage::contains() expects parameter 1 to be object, boolean given in %s on line %d +NULL + +Warning: SplObjectStorage::contains() expects parameter 1 to be object, %unicode_string_optional% given in %s on line %d +NULL + +Warning: SplObjectStorage::contains() expects parameter 1 to be object, integer given in %s on line %d +NULL + +Warning: SplObjectStorage::contains() expects parameter 1 to be object, double given in %s on line %d +NULL + +Warning: SplObjectStorage::contains() expects parameter 1 to be object, null given in %s on line %d +NULL + diff --git a/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt b/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt new file mode 100644 index 0000000000..3fc883d5e1 --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt @@ -0,0 +1,17 @@ +--TEST-- +Check that SplObjectStorage::current returns NULL when storage is empty +--CREDITS-- +PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com) +--SKIPIF-- + +--FILE-- +current()); + +?> +--EXPECT-- +NULL + diff --git a/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt new file mode 100644 index 0000000000..a87dde95c6 --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt @@ -0,0 +1,45 @@ +--TEST-- +Check that SplObjectStorage::detach generate a warning and returns NULL when passed non-object param +--CREDITS-- +PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com) +--SKIPIF-- + +--FILE-- +detach($input)); +} + +?> +--EXPECTF-- +Warning: SplObjectStorage::detach() expects parameter 1 to be object, array given in %s on line %d +NULL + +Warning: SplObjectStorage::detach() expects parameter 1 to be object, boolean given in %s on line %d +NULL + +Warning: SplObjectStorage::detach() expects parameter 1 to be object, %unicode_string_optional% given in %s on line %d +NULL + +Warning: SplObjectStorage::detach() expects parameter 1 to be object, integer given in %s on line %d +NULL + +Warning: SplObjectStorage::detach() expects parameter 1 to be object, double given in %s on line %d +NULL + +Warning: SplObjectStorage::detach() expects parameter 1 to be object, null given in %s on line %d +NULL + diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt new file mode 100644 index 0000000000..96f809ebdc --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt @@ -0,0 +1,29 @@ +--TEST-- +Check that SplObjectStorage::unserialize returns NULL when non-string param is passed +--CREDITS-- +PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com) +--SKIPIF-- + +--FILE-- +unserialize($input)); +} + +?> +--EXPECTF-- +Warning: SplObjectStorage::unserialize() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: SplObjectStorage::unserialize() expects parameter 1 to be string, object given in %s on line %d +NULL + diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt new file mode 100644 index 0000000000..12d596b48a --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Check that SplObjectStorage::unserialize throws exception when numeric value passed +--CREDITS-- +PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com) +--SKIPIF-- + +--FILE-- +unserialize($input); + } catch(UnexpectedValueException $e) { + echo $e->getMessage() . PHP_EOL; + } +} + +?> +--EXPECTF-- +Error at offset %d of %d bytes +Error at offset %d of %d bytes +Error at offset %d of %d bytes +Error at offset %d of %d bytes +Error at offset %d of %d bytes + diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt new file mode 100644 index 0000000000..cb111853c9 --- /dev/null +++ b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt @@ -0,0 +1,21 @@ +--TEST-- +Check that SplObjectStorage::unserialize throws exception when NULL passed +--CREDITS-- +PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com) +--SKIPIF-- + +--FILE-- +unserialize(NULL); +} catch(UnexpectedValueException $e) { + echo $e->getMessage(); +} + +?> +--EXPECTF-- +Empty serialized string cannot be empty +