wimartin Fri, 29 Jan 2010 15:43:39 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=294230
Log:
Backport some SplObjectStorage tests to 5.2
Changed paths:
A
php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt
A
php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt 2010-01-29 15:43:39 UTC (rev 294230)
@@ -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 ([email protected])
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+var_dump($s->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
+
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt 2010-01-29 15:43:39 UTC (rev 294230)
@@ -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 ([email protected])
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->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
+
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt 2010-01-29 15:43:39 UTC (rev 294230)
@@ -0,0 +1,17 @@
+--TEST--
+Check that SplObjectStorage::current returns NULL when storage is empty
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott ([email protected])
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+var_dump($s->current());
+
+?>
+--EXPECT--
+NULL
+
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt 2010-01-29 15:43:39 UTC (rev 294230)
@@ -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 ([email protected])
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->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
+
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt 2010-01-29 15:43:39 UTC (rev 294230)
@@ -0,0 +1,29 @@
+--TEST--
+Check that SplObjectStorage::unserialize returns NULL when non-string param is passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott ([email protected])
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ new stdClass(),
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->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
+
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt 2010-01-29 15:43:39 UTC (rev 294230)
@@ -0,0 +1,36 @@
+--TEST--
+Check that SplObjectStorage::unserialize throws exception when numeric value passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott ([email protected])
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$data_provider = array(
+ 12345,
+ 1.2345,
+ PHP_INT_MAX,
+ 'x:rubbish', // rubbish after the 'x:' prefix
+ 'x:i:2;O:8:"stdClass":0:{},s:5:"value";;m:a:0:{}',
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ try {
+ $s->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
+
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt 2010-01-29 15:43:39 UTC (rev 294230)
@@ -0,0 +1,21 @@
+--TEST--
+Check that SplObjectStorage::unserialize throws exception when NULL passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott ([email protected])
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+try {
+ $s->unserialize(NULL);
+} catch(UnexpectedValueException $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Empty serialized string cannot be empty
+
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php