Annotation of embedaddon/php/ext/standard/tests/array/ksort_variation11.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test ksort() function : usage variations - sort heredoc strings  
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : bool ksort ( array &$array [, int $sort_flags] )
        !             6:  * Description: Sort an array by key, maintaining key to data correlation
        !             7:  * Source code: ext/standard/array.c
        !             8: */
        !             9: 
        !            10: /*
        !            11:  * testing ksort() by providing array of heredoc strings for $array argument with
        !            12:  * following flag values:
        !            13:  *  1.flag value as defualt
        !            14:  *  2.SORT_REGULAR - compare items normally
        !            15:  *  3.SORT_STRING  - compare items as strings
        !            16: */
        !            17: 
        !            18: echo "*** Testing ksort() : usage variations ***\n";
        !            19: 
        !            20: // Different heredoc strings to be sorted 
        !            21: $simple_heredoc1 =<<<EOT
        !            22: Heredoc
        !            23: EOT;
        !            24: 
        !            25: $simple_heredoc2 =<<<EOT
        !            26: HEREDOC
        !            27: EOT;
        !            28: 
        !            29: $multiline_heredoc =<<<EOT
        !            30: heredoc string\twith!@# and 123
        !            31: Test this!!!
        !            32: EOT;
        !            33: 
        !            34: $array = array (
        !            35:   $simple_heredoc1 => "Heredoc", 
        !            36:   $simple_heredoc2 => "HEREDOC",
        !            37:   $multiline_heredoc => "heredoc string\twith!@# and 123\nTest this!!!"
        !            38: );
        !            39: 
        !            40: echo "\n-- Testing ksort() by supplying heredoc string array, 'flag' value is defualt --\n";
        !            41: $temp_array = $array;
        !            42: var_dump(ksort($temp_array) ); // expecting : bool(true)
        !            43: var_dump($temp_array);
        !            44: 
        !            45: echo "\n-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_REGULAR --\n";
        !            46: $temp_array = $array;
        !            47: var_dump(ksort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
        !            48: var_dump($temp_array);
        !            49: 
        !            50: echo "\n-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_STRING --\n";
        !            51: $temp_array = $array;
        !            52: var_dump(ksort($temp_array, SORT_STRING) ); // expecting : bool(true)
        !            53: var_dump($temp_array);
        !            54: 
        !            55: echo "Done\n";
        !            56: ?>
        !            57: --EXPECTF--
        !            58: *** Testing ksort() : usage variations ***
        !            59: 
        !            60: -- Testing ksort() by supplying heredoc string array, 'flag' value is defualt --
        !            61: bool(true)
        !            62: array(3) {
        !            63:   ["HEREDOC"]=>
        !            64:   string(7) "HEREDOC"
        !            65:   ["Heredoc"]=>
        !            66:   string(7) "Heredoc"
        !            67:   ["heredoc string     with!@# and 123
        !            68: Test this!!!"]=>
        !            69:   string(43) "heredoc string   with!@# and 123
        !            70: Test this!!!"
        !            71: }
        !            72: 
        !            73: -- Testing ksort() by supplying heredoc string array, 'flag' = SORT_REGULAR --
        !            74: bool(true)
        !            75: array(3) {
        !            76:   ["HEREDOC"]=>
        !            77:   string(7) "HEREDOC"
        !            78:   ["Heredoc"]=>
        !            79:   string(7) "Heredoc"
        !            80:   ["heredoc string     with!@# and 123
        !            81: Test this!!!"]=>
        !            82:   string(43) "heredoc string   with!@# and 123
        !            83: Test this!!!"
        !            84: }
        !            85: 
        !            86: -- Testing ksort() by supplying heredoc string array, 'flag' = SORT_STRING --
        !            87: bool(true)
        !            88: array(3) {
        !            89:   ["HEREDOC"]=>
        !            90:   string(7) "HEREDOC"
        !            91:   ["Heredoc"]=>
        !            92:   string(7) "Heredoc"
        !            93:   ["heredoc string     with!@# and 123
        !            94: Test this!!!"]=>
        !            95:   string(43) "heredoc string   with!@# and 123
        !            96: Test this!!!"
        !            97: }
        !            98: Done

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