function NaturalSortTest::testNoLanguageFallback

Tests the fallback to strnatcasecmp() when no language is available.

File

core/tests/Drupal/Tests/Core/Utility/NaturalSortTest.php, line 65

Class

NaturalSortTest
Tests Drupal\Core\Utility\NaturalSort.

Namespace

Drupal\Tests\Core\Utility

Code

public function testNoLanguageFallback() : void {
  // Without a language code and without a language manager service the
  // comparison falls back to strnatcasecmp(), which compares bytes and
  // sorts accented characters after all ASCII characters.
  $this->assertGreaterThan(0, NaturalSort::strnatcasecmp('Émission', 'Format'));
  $this->assertLessThan(0, NaturalSort::strnatcasecmp('Format', 'Émission'));
  $this->assertGreaterThan(0, NaturalSort::strnatcasecmp('Format 100x100', 'Format 10x10'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.