function LocaleLookupTest::testResolveCacheMissNoTranslation

Same name in other branches
  1. 9 core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testResolveCacheMissNoTranslation()
  2. 8.9.x core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testResolveCacheMissNoTranslation()
  3. 11.x 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 254

Class

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

Namespace

Drupal\Tests\locale\Unit

Code

public function testResolveCacheMissNoTranslation() : void {
    $string = $this->createMock('Drupal\\locale\\StringInterface');
    $string->expects($this->once())
        ->method('addLocation')
        ->willReturnSelf();
    $this->storage
        ->expects($this->once())
        ->method('findTranslation')
        ->willReturn(NULL);
    $this->storage
        ->expects($this->once())
        ->method('createString')
        ->willReturn($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,
    ])
        ->onlyMethods([
        'persist',
    ])
        ->getMock();
    $locale_lookup->expects($this->never())
        ->method('persist');
    $this->assertTrue($locale_lookup->get('test'));
}

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