Annotation of embedaddon/php/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test ReflectionMethod::getClosure() function : error functionality
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : public mixed ReflectionFunction::getClosure()
        !             6:  * Description: Returns a dynamically created closure for the method
        !             7:  * Source code: ext/reflection/php_reflection.c
        !             8:  * Alias to functions:
        !             9:  */
        !            10: 
        !            11: echo "*** Testing ReflectionMethod::getClosure() : error conditions ***\n";
        !            12: 
        !            13: class StaticExample
        !            14: {
        !            15:        static function foo()
        !            16:        {
        !            17:                var_dump( "Static Example class, Hello World!" );
        !            18:        }
        !            19: }
        !            20: 
        !            21: class Example
        !            22: {
        !            23:        public $bar = 42;
        !            24:        public function foo()
        !            25:        {
        !            26:                var_dump( "Example class, bar: " . $this->bar );
        !            27:        }
        !            28: }
        !            29: 
        !            30: // Initialize classes
        !            31: $class = new ReflectionClass( 'Example' );
        !            32: $staticclass = new ReflectionClass( 'StaticExample' );
        !            33: $method = $class->getMethod( 'foo' );
        !            34: $staticmethod = $staticclass->getMethod( 'foo' );
        !            35: $object = new Example();
        !            36: $fakeobj = new StdClass();
        !            37: 
        !            38: echo "\n-- Testing ReflectionMethod::getClosure() function with more than expected no. of arguments --\n";
        !            39: var_dump( $staticmethod->getClosure( 'foobar' ) );
        !            40: var_dump( $staticmethod->getClosure( 'foo', 'bar' ) );
        !            41: var_dump( $method->getClosure( $object, 'foobar' ) );
        !            42: 
        !            43: echo "\n-- Testing ReflectionMethod::getClosure() function with Zero arguments --\n";
        !            44: $closure = $method->getClosure();
        !            45: 
        !            46: echo "\n-- Testing ReflectionMethod::getClosure() function with Zero arguments --\n";
        !            47: try {
        !            48:         var_dump( $method->getClosure( $fakeobj ) );
        !            49: } catch( Exception $e ) {
        !            50:         var_dump( $e->getMessage() );
        !            51: }
        !            52: 
        !            53: ?>
        !            54: ===DONE===
        !            55: --EXPECTF--
        !            56: *** Testing ReflectionMethod::getClosure() : error conditions ***
        !            57: 
        !            58: -- Testing ReflectionMethod::getClosure() function with more than expected no. of arguments --
        !            59: object(Closure)#%d (0) {
        !            60: }
        !            61: object(Closure)#%d (0) {
        !            62: }
        !            63: 
        !            64: Warning: ReflectionMethod::getClosure() expects exactly 1 parameter, 2 given in %s on line %d
        !            65: NULL
        !            66: 
        !            67: -- Testing ReflectionMethod::getClosure() function with Zero arguments --
        !            68: 
        !            69: Warning: ReflectionMethod::getClosure() expects exactly 1 parameter, 0 given in %s on line %d
        !            70: 
        !            71: -- Testing ReflectionMethod::getClosure() function with Zero arguments --
        !            72: string(72) "Given object is not an instance of the class this method was declared in"
        !            73: ===DONE===

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