Annotation of embedaddon/php/ext/standard/tests/dir/dir_variation2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test dir() function : usage variations - unexpected value for 'context' argument
        !             3: --FILE--
        !             4: <?php
        !             5: /* 
        !             6:  * Prototype  : object dir(string $directory[, resource $context])
        !             7:  * Description: Directory class with properties, handle and class and methods read, rewind and close
        !             8:  * Source code: ext/standard/dir.c
        !             9:  */
        !            10: 
        !            11: /*
        !            12:  * Passing non resource values to 'context' argument of dir() and see
        !            13:  * that the function outputs proper warning messages wherever expected.
        !            14:  */
        !            15: 
        !            16: echo "*** Testing dir() : unexpected values for \$context argument ***\n";
        !            17: 
        !            18: // create the temporary directory
        !            19: $file_path = dirname(__FILE__);
        !            20: $directory = $file_path."/dir_variation2";
        !            21: @mkdir($directory);
        !            22: 
        !            23: // get an unset variable
        !            24: $unset_var = stream_context_create();
        !            25: unset($unset_var);
        !            26: 
        !            27: class classA
        !            28: {
        !            29:   public $var;
        !            30:   public function init() {
        !            31:     $this->var = 10;
        !            32:   }
        !            33: }
        !            34: 
        !            35: // heredoc string
        !            36: $heredoc = <<<EOT
        !            37: hello world
        !            38: EOT;
        !            39: 
        !            40: // unexpected values to be passed to $directory argument
        !            41: $unexpected_values = array (
        !            42:        // int data
        !            43: /*1*/  0,
        !            44:        1,
        !            45:        12345,
        !            46:        -2345,
        !            47: 
        !            48:        // float data
        !            49: /*5*/  10.5,
        !            50:        -10.5,
        !            51:        12.3456789000e10,
        !            52:        12.3456789000E-10,
        !            53:        .5,
        !            54: 
        !            55:        // array data
        !            56: /*10*/ array(),
        !            57:        array(0),
        !            58:        array(1),
        !            59:        array(1, 2),
        !            60:        array('color' => 'red', 'item' => 'pen'),
        !            61: 
        !            62: 
        !            63:        // null data
        !            64: /*15*/ NULL,
        !            65:        null,
        !            66: 
        !            67:        // boolean data
        !            68: /*17*/ true,
        !            69:        false,
        !            70:        TRUE,
        !            71:        FALSE,
        !            72: 
        !            73:        // empty data
        !            74: /*21*/ "",
        !            75:        '',
        !            76: 
        !            77:        // string data
        !            78: /*23*/ "string",
        !            79:        'string',
        !            80:        $heredoc,
        !            81: 
        !            82:        // object data
        !            83: /*26*/ new classA(),
        !            84: 
        !            85:        // undefined data
        !            86: /*27*/ @$undefined_var,
        !            87: 
        !            88:        // unset data
        !            89: /*28*/ @$unset_var
        !            90: );
        !            91: 
        !            92: // loop through various elements of $unexpected_values to check the behavior of dir()
        !            93: $iterator = 1;
        !            94: foreach( $unexpected_values as $unexpected_value ) {
        !            95:   echo "\n-- Iteration $iterator --";
        !            96:   var_dump( dir($directory, $unexpected_value) );
        !            97:   $iterator++;
        !            98: }
        !            99: 
        !           100: echo "Done";
        !           101: ?>
        !           102: --CLEAN--
        !           103: <?php
        !           104: $file_path = dirname(__FILE__);
        !           105: $directory = $file_path."/dir_variation2";
        !           106: 
        !           107: rmdir($directory);
        !           108: ?>
        !           109: --EXPECTF--
        !           110: *** Testing dir() : unexpected values for $context argument ***
        !           111: 
        !           112: -- Iteration 1 --
        !           113: Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
        !           114: NULL
        !           115: 
        !           116: -- Iteration 2 --
        !           117: Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
        !           118: NULL
        !           119: 
        !           120: -- Iteration 3 --
        !           121: Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
        !           122: NULL
        !           123: 
        !           124: -- Iteration 4 --
        !           125: Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
        !           126: NULL
        !           127: 
        !           128: -- Iteration 5 --
        !           129: Warning: dir() expects parameter 2 to be resource, double given in %s on line %d
        !           130: NULL
        !           131: 
        !           132: -- Iteration 6 --
        !           133: Warning: dir() expects parameter 2 to be resource, double given in %s on line %d
        !           134: NULL
        !           135: 
        !           136: -- Iteration 7 --
        !           137: Warning: dir() expects parameter 2 to be resource, double given in %s on line %d
        !           138: NULL
        !           139: 
        !           140: -- Iteration 8 --
        !           141: Warning: dir() expects parameter 2 to be resource, double given in %s on line %d
        !           142: NULL
        !           143: 
        !           144: -- Iteration 9 --
        !           145: Warning: dir() expects parameter 2 to be resource, double given in %s on line %d
        !           146: NULL
        !           147: 
        !           148: -- Iteration 10 --
        !           149: Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
        !           150: NULL
        !           151: 
        !           152: -- Iteration 11 --
        !           153: Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
        !           154: NULL
        !           155: 
        !           156: -- Iteration 12 --
        !           157: Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
        !           158: NULL
        !           159: 
        !           160: -- Iteration 13 --
        !           161: Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
        !           162: NULL
        !           163: 
        !           164: -- Iteration 14 --
        !           165: Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
        !           166: NULL
        !           167: 
        !           168: -- Iteration 15 --
        !           169: Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
        !           170: NULL
        !           171: 
        !           172: -- Iteration 16 --
        !           173: Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
        !           174: NULL
        !           175: 
        !           176: -- Iteration 17 --
        !           177: Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
        !           178: NULL
        !           179: 
        !           180: -- Iteration 18 --
        !           181: Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
        !           182: NULL
        !           183: 
        !           184: -- Iteration 19 --
        !           185: Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
        !           186: NULL
        !           187: 
        !           188: -- Iteration 20 --
        !           189: Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
        !           190: NULL
        !           191: 
        !           192: -- Iteration 21 --
        !           193: Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
        !           194: NULL
        !           195: 
        !           196: -- Iteration 22 --
        !           197: Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
        !           198: NULL
        !           199: 
        !           200: -- Iteration 23 --
        !           201: Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
        !           202: NULL
        !           203: 
        !           204: -- Iteration 24 --
        !           205: Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
        !           206: NULL
        !           207: 
        !           208: -- Iteration 25 --
        !           209: Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
        !           210: NULL
        !           211: 
        !           212: -- Iteration 26 --
        !           213: Warning: dir() expects parameter 2 to be resource, object given in %s on line %d
        !           214: NULL
        !           215: 
        !           216: -- Iteration 27 --
        !           217: Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
        !           218: NULL
        !           219: 
        !           220: -- Iteration 28 --
        !           221: Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
        !           222: NULL
        !           223: Done

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