function LocaleLookupTest::testGetCid

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

Tests get cid.

Attributes

#[DataProvider('getCidProvider')]

File

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

Class

LocaleLookupTest
Tests Drupal\locale\LocaleLookup.

Namespace

Drupal\Tests\locale\Unit

Code

public function testGetCid(array $roles, $expected) : void {
  $this->storage
    ->expects($this->never())
    ->method('findTranslation');
  $this->user = $this->createStub(AccountInterface::class);
  $this->user
    ->method('getRoles')
    ->willReturn($roles);
  $container = new ContainerBuilder();
  $container->set('current_user', $this->user);
  \Drupal::setContainer($container);
  $locale_lookup = new LocaleLookup('en', 'irrelevant', $this->storage, $this->createStub(CacheBackendInterface::class), $this->lock, $this->configFactory, $this->languageManager, $this->requestStack);
  $o = new \ReflectionObject($locale_lookup);
  $method = $o->getMethod('getCid');
  $cid = $method->invoke($locale_lookup, 'getCid');
  $this->assertEquals($expected, $cid);
}

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