You are here

public function LocaleLookupTest::testResolveCacheMissNoTranslation in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testResolveCacheMissNoTranslation()
  2. 10 core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testResolveCacheMissNoTranslation()

Tests locale lookups without a found translation.

@covers ::resolveCacheMiss

File

core/modules/locale/tests/src/Unit/LocaleLookupTest.php, line 250

Class

LocaleLookupTest
@coversDefaultClass \Drupal\locale\LocaleLookup @group locale

Namespace

Drupal\Tests\locale\Unit

Code

public function testResolveCacheMissNoTranslation() {
  $string = $this
    ->createMock('Drupal\\locale\\StringInterface');
  $string
    ->expects($this
    ->once())
    ->method('addLocation')
    ->will($this
    ->returnSelf());
  $this->storage
    ->expects($this
    ->once())
    ->method('findTranslation')
    ->will($this
    ->returnValue(NULL));
  $this->storage
    ->expects($this
    ->once())
    ->method('createString')
    ->will($this
    ->returnValue($string));
  $request = Request::create('/test');
  $this->requestStack
    ->push($request);
  $locale_lookup = $this
    ->getMockBuilder('Drupal\\locale\\LocaleLookup')
    ->setConstructorArgs([
    'en',
    'irrelevant',
    $this->storage,
    $this->cache,
    $this->lock,
    $this->configFactory,
    $this->languageManager,
    $this->requestStack,
  ])
    ->setMethods([
    'persist',
  ])
    ->getMock();
  $locale_lookup
    ->expects($this
    ->never())
    ->method('persist');
  $this
    ->assertTrue($locale_lookup
    ->get('test'));
}