assertEquals($expected,$e->getMessage(),$message); } $error_msg=intl_get_error_message(); $expected="collator_sort_internal: unable to parse input params: U_ILLEGAL_ARGUMENT_ERROR"; //$expected="U_USING_FALLBACK_WARNING"; $this->assertEquals($expected,$error_msg,$message); $GLOBALS['oo-mode']=false; // Sort an array in SORT_REGULAR mode using en_US locale. $test_arrays = array( array( 'abc', 'abd', 'aaa' ), array( 'm' , '1' , '_' ), array( 'a' , 'aaa', 'aa' ), array( 'ba' , 'b' , 'ab' ), array( 'e' , 'c' , 'a' ), array( '100', '25' , '36' ), array( 5 , '30' , 2 ), array( 'd' , '' , ' a' ), array( 'd ' , 'f ' , ' a' ), array( 'a' , null , '3' ), array( 'y' , 'k' , 'i' ) ); $expected_arrays=array( array ( 0 => 'aaa', 1 => 'abc', 2 => 'abd', ), array ( 0 => '_', 1 => '1', 2 => 'm', ), array ( 0 => 'a', 1 => 'aa', 2 => 'aaa', ), array ( 0 => 'ab', 1 => 'b', 2 => 'ba', ), array ( 0 => 'a', 1 => 'c', 2 => 'e', ), array ( 0 => '25', 1 => '36', 2 => '100', ), array ( 0 => 2, 1 => 5, 2 => '30', ), array ( 0 => '', 1 => ' a', 2 => 'd', ), array ( 0 => ' a', 1 => 'd ', 2 => 'f ', ), array ( 0 => NULL, 1 => '3', 2 => 'a', ), array ( 0 => 'i', 1 => 'k', 2 => 'y', ) ); $expectedbool=array(true,true,true,true,true,true,true,true,true,true,true); $expectedmd5=array ( "e8f1cd28133d79ecd660002f1c660d0e", "c2ded12173dd2996927378cae37eb275", "54071c968d71cb98c5d379145f8d7d38", "19abe63d6f6dfef65b0e3c9ab4826b07", "9a8dc0a9bc771368c2f1fc3d02754610", "ab530b060e5e54a65bfb8b9f8fc61870", "0718dd838509017bded2ed307a6e785f", "923d65739c5219c634616ffd100a50e4", "289bc2f28e87d3201ec9d7e8477ae1b0", "de0fd958484f2377a645835d7fbcf124", "dd2b8f0adb37c45d528cad1a0cc0f361", ); do{ $coll = ut_coll_create( "en_US" ); foreach( $test_arrays as $key=>$test_array ) { $message="Sort an array in SORT_REGULAR mode using en_US locale,$test_array array $key"; // Try to sort test data. $res_val = ut_coll_sort( $coll, $test_array, Collator::SORT_REGULAR ); // Return output data. $this->assertEquals($expected_arrays[$key],$test_array,$message); $message="Sort an array in SORT_REGULAR mode using en_US locale , res_val array $key"; $this->assertEquals($expectedbool[$key],$res_val,$message); // Return output data. $res_dump = "\n" . dump( $test_array ) . "\n Result: " . dump( $res_val ); // Preppend test signature to output string $md5 = md5( $res_dump ); $message="Sort an array in SORT_REGULAR mode using en_US locale, md5 array $key"; $this->assertEquals($expectedmd5[$key],$md5,$message); } if($GLOBALS['oo-mode']==true)$GLOBALS['oo-mode']=false; else $GLOBALS['oo-mode']=true; }while($GLOBALS['oo-mode']); // Sort in en_US locale with SORT_STRING flag $test_arrays_1 = array( array( '100', '25' , '36' ), array( 5 , '30' , 2 ), array( 'd' , '' , ' a' ), array( 'y' , 'k' , 'i' ) ); $expected_arrays_1=array( array ( 0 => '100', 1 => '25', 2 => '36', ), array ( 0 => 2, 1 => '30', 2 => 5, ), array ( 0 => '', 1 => ' a', 2 => 'd', ), array ( 0 => 'i', 1 => 'k', 2 => 'y', ) ); $expectedbool_1=array(true,true,true,true); $expectedmd5_1=array ( "1e6b4d6f7df9d4580317634ea46d8208", "cec115dc9850b98dfbdf102efa09e61b", "923d65739c5219c634616ffd100a50e4", "dd2b8f0adb37c45d528cad1a0cc0f361" ); do{ $coll = ut_coll_create( "en_US" ); foreach( $test_arrays_1 as $key=>$test_array_1 ) { $message="Sort an array in SORT_STRING mode using en_US locale,$test_array array $key"; // Try to sort test data. $res_val = ut_coll_sort( $coll, $test_array_1, Collator::SORT_STRING ); // Return output data. $this->assertEquals($expected_arrays_1[$key],$test_array_1,$message); $message="Sort an array in SORT_STRING mode using en_US locale , res_val array $key"; $this->assertEquals($expectedbool_1[$key],$res_val,$message); // Return output data. $res_dump = "\n" . dump( $test_array_1 ) . "\n Result: " . dump( $res_val ); // Preppend test signature to output string $md5 = md5( $res_dump ); $message="Sort an array in SORT_STRING mode using en_US locale, md5 array $key"; $this->assertEquals($expectedmd5_1[$key],$md5,$message); } if($GLOBALS['oo-mode']==true)$GLOBALS['oo-mode']=false; else $GLOBALS['oo-mode']=true; }while($GLOBALS['oo-mode']); // Sort a non-ASCII array using ru_RU locale. $test_arrays_2 = array( array( 'абг', 'абв', 'ааа', 'abc' ), array( 'аа', 'ааа' , 'а' ) ); $expected_arrays_2=array( array ( 0 => 'abc', 1 => 'ааа', 2 => 'абв', 3 => 'абг', ), array ( 0 => 'а', 1 => 'аа', 2 => 'ааа', ) ); $expectedbool_2=array(true,true); $expectedmd5_2=array ( "ca0e38a2e3147dd97070f2128f140934", "91480b10473a0c96a4cd6d88c23c577a", ); do{ $coll = ut_coll_create( "ru_RU" ); foreach( $test_arrays_2 as $key=>$test_array_2 ) { $message="Sort an array in SORT_STRING mode using ru_RU locale,$test_array array $key"; // Try to sort test data. $res_val = ut_coll_sort( $coll, $test_array_2, Collator::SORT_REGULAR ); // Return output data. $this->assertEquals($expected_arrays_2[$key],$test_array_2,$message); $message="Sort an array in SORT_STRING mode using ru_RU locale , res_val array $key"; $this->assertEquals($expectedbool_2[$key],$res_val,$message); // Return output data. $res_dump = "\n" . dump( $test_array_2 ) . "\n Result: " . dump( $res_val ); // Preppend test signature to output string $md5 = md5( $res_dump ); $message="Sort an array in SORT_STRING mode using ru_RU locale, md5 array $key"; $this->assertEquals($expectedmd5_2[$key],$md5,$message); } if($GLOBALS['oo-mode']==true)$GLOBALS['oo-mode']=false; else $GLOBALS['oo-mode']=true; }while($GLOBALS['oo-mode']); // Sort an array using Lithuanian locale. $test_arrays_3 = array( array( 'y' , 'k' , 'i' ) ); $expected_arrays_3=array( array ( 0 => 'i', 1 => 'y', 2 => 'k', ) ); $expectedbool_3=array(true); $expectedmd5_3=array ( "fdd3fe3981476039164aa000bf9177f2", ); do{ $coll = ut_coll_create( "lt_LT" ); foreach( $test_arrays_3 as $key=>$test_array_3 ) { $message="Sort an array in SORT_STRING mode using lt_LT locale,$test_array array $key"; // Try to sort test data. $res_val = ut_coll_sort( $coll, $test_array_3, Collator::SORT_REGULAR ); // Return output data. $this->assertEquals($expected_arrays_3[$key],$test_array_3,$message); $message="Sort an array in SORT_STRING mode using lt_LT locale , res_val array $key"; $this->assertEquals($expectedbool_3[$key],$res_val,$message); // Return output data. $res_dump = "\n" . dump( $test_array_3 ) . "\n Result: " . dump( $res_val ); // Preppend test signature to output string $md5 = md5( $res_dump ); $message="Sort an array in SORT_STRING mode using lt_LT locale, md5 array $key"; $this->assertEquals($expectedmd5_3[$key],$md5,$message); } if($GLOBALS['oo-mode']==true)$GLOBALS['oo-mode']=false; else $GLOBALS['oo-mode']=true; }while($GLOBALS['oo-mode']); // Sort objects using en_US locale. do{ $coll_1=ut_coll_create("en_US"); $coll_2=ut_coll_create("lt_LT"); $coll_3=ut_coll_create("zh_CN"); $test_arrays_4 = array( array($coll_1 ,$coll_2 ,$coll_3 ) ); $expected_arrays_4=array( array ( 0 => $coll_1, 1 => $coll_2, 2 => $coll_3, ) ); $expectedbool_4=array(true); $expectedmd5_4=array ( "615c660b8ca471b8641c09c9906ec124", ); $coll = ut_coll_create( "en_US" ); foreach( $test_arrays_4 as $key=>$test_array_4 ) { $message=" Sort objects using en_US locale,$test_array array $key"; // Try to sort test data. $res_val = ut_coll_sort( $coll, $test_array_4); // Return output data. $this->assertEquals($expected_arrays_4[$key],$test_array_4,$message); $message=" Sort objects using en_US locale , res_val array $key"; $this->assertEquals($expectedbool_4[$key],$res_val,$message); // Return output data. $res_dump = "\n" . dump( $test_array_4 ) . "\n Result: " . dump( $res_val ); // Preppend test signature to output string $md5 = md5( $res_dump ); $message=" Sort objects using en_US locale, md5 array $key"; $this->assertEquals($expectedmd5_4[$key],$md5,$message); } if($GLOBALS['oo-mode']==true)$GLOBALS['oo-mode']=false; else $GLOBALS['oo-mode']=true; }while($GLOBALS['oo-mode']); } } //end of class YPHPINTLTest ?>