function ConfigNamesMapperTest::testHasTranslation

Same name in other branches
  1. 8.9.x core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest::testHasTranslation()
  2. 10 core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest::testHasTranslation()
  3. 11.x core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest::testHasTranslation()

Tests ConfigNamesMapper::hasTranslation().

@dataProvider providerTestHasTranslation

Parameters

array $mock_return_values: An array of values that the mocked configuration mapper manager should return for hasTranslation().

bool $expected: The expected return value of ConfigNamesMapper::hasTranslation().

File

core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php, line 596

Class

ConfigNamesMapperTest
Tests the functionality provided by the configuration names mapper.

Namespace

Drupal\Tests\config_translation\Unit

Code

public function testHasTranslation(array $mock_return_values, $expected) {
    $language = new Language();
    // As the configuration names are arbitrary, simply use integers.
    $config_names = range(1, count($mock_return_values));
    $this->configNamesMapper
        ->setConfigNames($config_names);
    $map = [];
    foreach ($config_names as $i => $config_name) {
        $map[] = [
            $config_name,
            $language->getId(),
            $mock_return_values[$i],
        ];
    }
    $this->localeConfigManager
        ->expects($this->any())
        ->method('hasTranslation')
        ->willReturnMap($map);
    $result = $this->configNamesMapper
        ->hasTranslation($language);
    $this->assertSame($expected, $result);
}

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