arrayObject___construct_error1.phpt 776 B

12345678910111213141516171819202122232425
  1. --TEST--
  2. SPL: ArrayObject::__construct with bad iterator.
  3. --FILE--
  4. <?php
  5. echo "Bad iterator type:\n";
  6. $a = new stdClass;
  7. $a->p = 1;
  8. try {
  9. var_dump(new ArrayObject($a, 0, "Exception"));
  10. } catch (InvalidArgumentException $e) {
  11. echo $e->getMessage() . "(" . $e->getLine() . ")\n";
  12. }
  13. echo "Non-existent class:\n";
  14. try {
  15. var_dump(new ArrayObject(new stdClass, 0, "nonExistentClassName"));
  16. } catch (InvalidArgumentException $e) {
  17. echo $e->getMessage() . "(" . $e->getLine() . ")\n";
  18. }
  19. ?>
  20. --EXPECTF--
  21. Bad iterator type:
  22. ArrayObject::__construct() expects parameter 3 to be a class name derived from Iterator, 'Exception' given(6)
  23. Non-existent class:
  24. ArrayObject::__construct() expects parameter 3 to be a class name derived from Iterator, 'nonExistentClassName' given(13)