Annotation of embedaddon/php/ext/standard/tests/array/krsort_variation10.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test krsort() function : usage variations - sort heredoc strings  
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : bool krsort ( array &$array [, int $sort_flags] )
                      6:  * Description: Sort an array by key in reverse order, maintaining key to data correlation
                      7:  * Source code: ext/standard/array.c
                      8: */
                      9: 
                     10: /*
                     11:  * testing krsort() 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 krsort() : 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 krsort() by supplying heredoc string array, 'flag' value is defualt --\n";
                     41: $temp_array = $array;
                     42: var_dump(krsort($temp_array) ); // expecting : bool(true)
                     43: var_dump($temp_array);
                     44: 
                     45: echo "\n-- Testing krsort() by supplying heredoc string array, 'flag' = SORT_REGULAR --\n";
                     46: $temp_array = $array;
                     47: var_dump(krsort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
                     48: var_dump($temp_array);
                     49: 
                     50: echo "\n-- Testing krsort() by supplying heredoc string array, 'flag' = SORT_STRING --\n";
                     51: $temp_array = $array;
                     52: var_dump(krsort($temp_array, SORT_STRING) ); // expecting : bool(true)
                     53: var_dump($temp_array);
                     54: 
                     55: echo "Done\n";
                     56: ?>
                     57: --EXPECTF--
                     58: *** Testing krsort() : usage variations ***
                     59: 
                     60: -- Testing krsort() by supplying heredoc string array, 'flag' value is defualt --
                     61: bool(true)
                     62: array(3) {
                     63:   ["heredoc string     with!@# and 123
                     64: Test this!!!"]=>
                     65:   string(43) "heredoc string   with!@# and 123
                     66: Test this!!!"
                     67:   ["Heredoc"]=>
                     68:   string(7) "Heredoc"
                     69:   ["HEREDOC"]=>
                     70:   string(7) "HEREDOC"
                     71: }
                     72: 
                     73: -- Testing krsort() by supplying heredoc string array, 'flag' = SORT_REGULAR --
                     74: bool(true)
                     75: array(3) {
                     76:   ["heredoc string     with!@# and 123
                     77: Test this!!!"]=>
                     78:   string(43) "heredoc string   with!@# and 123
                     79: Test this!!!"
                     80:   ["Heredoc"]=>
                     81:   string(7) "Heredoc"
                     82:   ["HEREDOC"]=>
                     83:   string(7) "HEREDOC"
                     84: }
                     85: 
                     86: -- Testing krsort() by supplying heredoc string array, 'flag' = SORT_STRING --
                     87: bool(true)
                     88: array(3) {
                     89:   ["heredoc string     with!@# and 123
                     90: Test this!!!"]=>
                     91:   string(43) "heredoc string   with!@# and 123
                     92: Test this!!!"
                     93:   ["Heredoc"]=>
                     94:   string(7) "Heredoc"
                     95:   ["HEREDOC"]=>
                     96:   string(7) "HEREDOC"
                     97: }
                     98: Done

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