You are here

public function LocaleLookupTest::testResolveCacheMissNoTranslation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 249
Contains \Drupal\Tests\locale\Unit\LocaleLookupTest.

Class

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

Namespace

Drupal\Tests\locale\Unit

Code

public function testResolveCacheMissNoTranslation() {
  $string = $this
    ->getMock('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(array(
    'en',
    'irrelevant',
    $this->storage,
    $this->cache,
    $this->lock,
    $this->configFactory,
    $this->languageManager,
    $this->requestStack,
  ))
    ->setMethods(array(
    'persist',
  ))
    ->getMock();
  $locale_lookup
    ->expects($this
    ->never())
    ->method('persist');
  $this
    ->assertTrue($locale_lookup
    ->get('test'));
}