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()

@covers ::getCid

@dataProvider getCidProvider

File

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

Class

LocaleLookupTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21locale%21src%21LocaleLookup.php/class/LocaleLookup/9" 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 testGetCid(array $roles, $expected) {
    $this->user = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
    $this->user
        ->expects($this->any())
        ->method('getRoles')
        ->willReturn($roles);
    $container = new ContainerBuilder();
    $container->set('current_user', $this->user);
    \Drupal::setContainer($container);
    $locale_lookup = $this->getMockBuilder('Drupal\\locale\\LocaleLookup')
        ->setConstructorArgs([
        'en',
        'irrelevant',
        $this->storage,
        $this->cache,
        $this->lock,
        $this->configFactory,
        $this->languageManager,
        $this->requestStack,
    ])
        ->getMock();
    $o = new \ReflectionObject($locale_lookup);
    $method = $o->getMethod('getCid');
    $method->setAccessible(TRUE);
    $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.