Annotation of embedaddon/php/ext/standard/tests/class_object/interface_exists_variation1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test interface_exists() function : usage variation 
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : bool interface_exists(string classname [, bool autoload])
        !             6:  * Description: Checks if the class exists 
        !             7:  * Source code: Zend/zend_builtin_functions.c
        !             8:  * Alias to functions: 
        !             9:  */
        !            10: 
        !            11: echo "*** Testing interface_exists() : usage variation ***\n";
        !            12: 
        !            13: // Initialise function arguments not being substituted (if any)
        !            14: $autoload = true;
        !            15: 
        !            16: //get an unset variable
        !            17: $unset_var = 10;
        !            18: unset ($unset_var);
        !            19: 
        !            20: // define some classes
        !            21: class classWithToString
        !            22: {
        !            23:        public function __toString() {
        !            24:                return "Class A object";
        !            25:        }
        !            26: }
        !            27: 
        !            28: class classWithoutToString
        !            29: {
        !            30: }
        !            31: 
        !            32: // heredoc string
        !            33: $heredoc = <<<EOT
        !            34: hello world
        !            35: EOT;
        !            36: 
        !            37: // add arrays
        !            38: $index_array = array (1, 2, 3);
        !            39: $assoc_array = array ('one' => 1, 'two' => 2);
        !            40: 
        !            41: //array of values to iterate over
        !            42: $inputs = array(
        !            43: 
        !            44:       // int data
        !            45:       'int 0' => 0,
        !            46:       'int 1' => 1,
        !            47:       'int 12345' => 12345,
        !            48:       'int -12345' => -2345,
        !            49: 
        !            50:       // float data
        !            51:       'float 10.5' => 10.5,
        !            52:       'float -10.5' => -10.5,
        !            53:       'float 12.3456789000e10' => 12.3456789000e10,
        !            54:       'float -12.3456789000e10' => -12.3456789000e10,
        !            55:       'float .5' => .5,
        !            56: 
        !            57:       // array data
        !            58:       'empty array' => array(),
        !            59:       'int indexed array' => $index_array,
        !            60:       'associative array' => $assoc_array,
        !            61:       'nested arrays' => array('foo', $index_array, $assoc_array),
        !            62: 
        !            63:       // null data
        !            64:       'uppercase NULL' => NULL,
        !            65:       'lowercase null' => null,
        !            66: 
        !            67:       // boolean data
        !            68:       'lowercase true' => true,
        !            69:       'lowercase false' =>false,
        !            70:       'uppercase TRUE' =>TRUE,
        !            71:       'uppercase FALSE' =>FALSE,
        !            72: 
        !            73:       // empty data
        !            74:       'empty string DQ' => "",
        !            75:       'empty string SQ' => '',
        !            76: 
        !            77:       // object data
        !            78:       'instance of classWithToString' => new classWithToString(),
        !            79:       'instance of classWithoutToString' => new classWithoutToString(),
        !            80: 
        !            81:       // undefined data
        !            82:       'undefined var' => @$undefined_var,
        !            83: 
        !            84:       // unset data
        !            85:       'unset var' => @$unset_var,
        !            86: );
        !            87: 
        !            88: // loop through each element of the array for classname
        !            89: 
        !            90: foreach($inputs as $key =>$value) {
        !            91:       echo "\n--$key--\n";
        !            92:       var_dump( interface_exists($value, $autoload) );
        !            93: };
        !            94: 
        !            95: ?>
        !            96: ===DONE===
        !            97: --EXPECTF--
        !            98: *** Testing interface_exists() : usage variation ***
        !            99: 
        !           100: --int 0--
        !           101: bool(false)
        !           102: 
        !           103: --int 1--
        !           104: bool(false)
        !           105: 
        !           106: --int 12345--
        !           107: bool(false)
        !           108: 
        !           109: --int -12345--
        !           110: bool(false)
        !           111: 
        !           112: --float 10.5--
        !           113: bool(false)
        !           114: 
        !           115: --float -10.5--
        !           116: bool(false)
        !           117: 
        !           118: --float 12.3456789000e10--
        !           119: bool(false)
        !           120: 
        !           121: --float -12.3456789000e10--
        !           122: bool(false)
        !           123: 
        !           124: --float .5--
        !           125: bool(false)
        !           126: 
        !           127: --empty array--
        !           128: 
        !           129: Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
        !           130: NULL
        !           131: 
        !           132: --int indexed array--
        !           133: 
        !           134: Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
        !           135: NULL
        !           136: 
        !           137: --associative array--
        !           138: 
        !           139: Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
        !           140: NULL
        !           141: 
        !           142: --nested arrays--
        !           143: 
        !           144: Warning: interface_exists() expects parameter 1 to be string, array given in %sinterface_exists_variation1.php on line %d
        !           145: NULL
        !           146: 
        !           147: --uppercase NULL--
        !           148: bool(false)
        !           149: 
        !           150: --lowercase null--
        !           151: bool(false)
        !           152: 
        !           153: --lowercase true--
        !           154: bool(false)
        !           155: 
        !           156: --lowercase false--
        !           157: bool(false)
        !           158: 
        !           159: --uppercase TRUE--
        !           160: bool(false)
        !           161: 
        !           162: --uppercase FALSE--
        !           163: bool(false)
        !           164: 
        !           165: --empty string DQ--
        !           166: bool(false)
        !           167: 
        !           168: --empty string SQ--
        !           169: bool(false)
        !           170: 
        !           171: --instance of classWithToString--
        !           172: bool(false)
        !           173: 
        !           174: --instance of classWithoutToString--
        !           175: 
        !           176: Warning: interface_exists() expects parameter 1 to be string, object given in %sinterface_exists_variation1.php on line %d
        !           177: NULL
        !           178: 
        !           179: --undefined var--
        !           180: bool(false)
        !           181: 
        !           182: --unset var--
        !           183: bool(false)
        !           184: ===DONE===

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