function LocaleLookupTest::testResolveCacheMissWithoutFallback

Same name in other branches
  1. 9 core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testResolveCacheMissWithoutFallback()
  2. 10 core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testResolveCacheMissWithoutFallback()
  3. 11.x core/modules/locale/tests/src/Unit/LocaleLookupTest.php \Drupal\Tests\locale\Unit\LocaleLookupTest::testResolveCacheMissWithoutFallback()

Tests locale lookups without fallback.

@covers ::resolveCacheMiss

File

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

Class

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

Namespace

Drupal\Tests\locale\Unit

Code

public function testResolveCacheMissWithoutFallback() {
    $args = [
        'language' => 'en',
        'source' => 'test',
        'context' => 'irrelevant',
    ];
    $result = (object) [
        'translation' => 'test',
    ];
    $this->cache
        ->expects($this->once())
        ->method('get')
        ->with('locale:en:irrelevant:anonymous', FALSE);
    $this->storage
        ->expects($this->once())
        ->method('findTranslation')
        ->with($this->equalTo($args))
        ->will($this->returnValue($result));
    $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->assertSame('test', $locale_lookup->get('test'));
}

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