Annotation of embedaddon/php/ext/spl/tests/spl_autoload_014.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: SPL: spl_autoload_unregister() with closures and invokables
        !             3: --FILE--
        !             4: <?php
        !             5: $closure = function($class) {
        !             6:   echo "closure called with class $class\n";
        !             7: };
        !             8: 
        !             9: class Autoloader {
        !            10:   private $dir;
        !            11:   public function __construct($dir) {
        !            12:     $this->dir = $dir;
        !            13:   }
        !            14:   public function __invoke($class) {
        !            15:     echo ("Autoloader('{$this->dir}') called with $class\n");
        !            16:   }
        !            17: }
        !            18: 
        !            19: class WorkingAutoloader {
        !            20:   public function __invoke($class) {
        !            21:     echo ("WorkingAutoloader() called with $class\n");
        !            22:     eval("class $class { }");
        !            23:   }
        !            24: }
        !            25: 
        !            26: $al1 = new Autoloader('d1');
        !            27: $al2 = new WorkingAutoloader('d2');
        !            28: 
        !            29: spl_autoload_register($closure);
        !            30: spl_autoload_register($al1);
        !            31: spl_autoload_register($al2);
        !            32: 
        !            33: $x = new TestX;
        !            34: 
        !            35: spl_autoload_unregister($closure);
        !            36: spl_autoload_unregister($al1);
        !            37: 
        !            38: $y = new TestY;
        !            39: 
        !            40: ?>
        !            41: ===DONE===
        !            42: --EXPECT--
        !            43: closure called with class TestX
        !            44: Autoloader('d1') called with TestX
        !            45: WorkingAutoloader() called with TestX
        !            46: WorkingAutoloader() called with TestY
        !            47: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>