error-auto-with-spl-nonstatic-autoload.phpt 757 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Error when registering autoload with non-static autoload already on SPL stack
  3. --SKIPIF--
  4. <?php
  5. if (!function_exists('spl_autoload_register')) {
  6. echo "skip - spl_autoload_register() not available";
  7. }
  8. if (version_compare(PHP_VERSION, '5.2.11', '>=')) {
  9. echo "skip - non-buggy version of PHP";
  10. }
  11. --FILE--
  12. <?php
  13. class NotStatic
  14. {
  15. public function autoload($class) {
  16. echo "Autoloading... $class" . PHP_EOL;
  17. eval("class $class {}");
  18. }
  19. }
  20. $obj = new NotStatic();
  21. spl_autoload_register(array($obj, 'autoload'));
  22. try {
  23. require '../library/HTMLPurifier.auto.php';
  24. } catch (Exception $e) {
  25. echo 'Caught error gracefully';
  26. assert('strpos($e->getMessage(), "44144") !== false');
  27. }
  28. --EXPECT--
  29. Caught error gracefully