You are here

public function LocaleLookupTest::testResolveCacheMissWithPersist 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::testResolveCacheMissWithPersist()

Tests locale lookups with persistent tracking.

@covers ::resolveCacheMiss

File

core/modules/locale/tests/src/Unit/LocaleLookupTest.php, line 217
Contains \Drupal\Tests\locale\Unit\LocaleLookupTest.

Class

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

Namespace

Drupal\Tests\locale\Unit

Code

public function testResolveCacheMissWithPersist() {
  $args = array(
    'language' => 'en',
    'source' => 'test',
    'context' => 'irrelevant',
  );
  $result = (object) array(
    'translation' => 'test',
  );
  $this->storage
    ->expects($this
    ->once())
    ->method('findTranslation')
    ->with($this
    ->equalTo($args))
    ->will($this
    ->returnValue($result));
  $this->configFactory = $this
    ->getConfigFactoryStub(array(
    'locale.settings' => array(
      'cache_strings' => TRUE,
    ),
  ));
  $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
    ->once())
    ->method('persist');
  $this
    ->assertSame('test', $locale_lookup
    ->get('test'));
}