/**
  * @dataProvider naturalSortDataProvider
  */
 public function testNaturalSortCompare($array, $sorted)
 {
     if (!class_exists('Collator')) {
         $this->markTestSkipped('The intl module is not available, natural sorting might not work as expected.');
         return;
     }
     $comparator = \OC\NaturalSort::getInstance();
     usort($array, array($comparator, 'compare'));
     $this->assertEquals($sorted, $array);
 }
Example #2
0
 /**
  * Compare two strings to provide a natural sort
  * @param string $a first string to compare
  * @param string $b second string to compare
  * @return -1 if $b comes before $a, 1 if $a comes before $b
  * or 0 if the strings are identical
  * @since 7.0.0
  */
 public static function naturalSortCompare($a, $b)
 {
     return \OC\NaturalSort::getInstance()->compare($a, $b);
 }
 /**
  * @dataProvider naturalSortDataProvider
  */
 public function testNaturalSortCompare($array, $sorted)
 {
     $comparator = \OC\NaturalSort::getInstance();
     usort($array, array($comparator, 'compare'));
     $this->assertEquals($sorted, $array);
 }