function NaturalSortTest::testCurrentLanguage

Tests that the current language is used when no language code is given.

Attributes

#[RequiresPhpExtension('intl')]

File

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

Class

NaturalSortTest
Tests Drupal\Core\Utility\NaturalSort.

Namespace

Drupal\Tests\Core\Utility

Code

public function testCurrentLanguage() : void {
  $language_manager = $this->createMock(LanguageManagerInterface::class);
  $language_manager->expects($this->atLeastOnce())
    ->method('getCurrentLanguage')
    ->willReturn(new Language([
    'id' => 'fr',
  ]));
  $container = new ContainerBuilder();
  $container->set('language_manager', $language_manager);
  \Drupal::setContainer($container);
  $this->assertLessThan(0, NaturalSort::strnatcasecmp('Émission', 'Format'));
  $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.