function LocaleLookupTest::testResolveCacheMissNoTranslation

Same name and namespace in other branches
  1. 9 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()
  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 245

Class

LocaleLookupTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21locale%21src%21LocaleLookup.php/class/LocaleLookup/8.9.x" title="A cache collector to allow for dynamic building of the locale cache." class="local">\Drupal\locale\LocaleLookup</a> @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'));
}

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