cvs: php-src /tests/classes array_access_013.phpt
| From: | Marcus Boerger | Date: | Tue, 19 Jul 2005 20:10:39 +0000 |
| Subject: | cvs: php-src /tests/classes array_access_013.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-32997@lists.php.net to get a copy of this message | ||
helly Tue Jul 19 16:10:39 2005 EDT
Added files:
/php-src/tests/classes array_access_013.phpt
Log:
- Add test to verify all ArrayAccess methods can throw
http://cvs.php.net/co.php/php-src/tests/classes/array_access_013.phpt?r=1.1&p=1
Index: php-src/tests/classes/array_access_013.phpt
+++ php-src/tests/classes/array_access_013.phpt
--TEST--
ZE2 arrayAcces & exceptions
--FILE--
<?php
class Test implements ArrayAccess
{
public function offsetExists($offset) { throw new Exception(__METHOD__); return false;
}
public function offsetGet($offset) { throw new Exception(__METHOD__); return
$offset; }
public function offsetSet($offset, $data ) { throw new Exception(__METHOD__); }
public function offsetUnset($offset) { throw new Exception(__METHOD__); }
}
$t = new Test;
try
{
echo isset($t[0]);
}
catch(Exception $e)
{
echo "Caught in " . $e->getMessage() . "()\n";
}
try
{
echo $t[0];
}
catch(Exception $e)
{
echo "Caught in " . $e->getMessage() . "()\n";
}
try
{
$t[0] = 1;
}
catch(Exception $e)
{
echo "Caught in " . $e->getMessage() . "()\n";
}
try
{
unset($t[0]);
}
catch(Exception $e)
{
echo "Caught in " . $e->getMessage() . "()\n";
}
?>
===DONE===
--EXPECT--
Caught in Test::offsetExists()
Caught in Test::offsetGet()
Caught in Test::offsetSet()
Caught in Test::offsetUnset()
===DONE===