function ConfigNamesMapperTest::testHasTranslatable

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

Tests ConfigNamesMapper::hasTranslatable().

@dataProvider providerTestHasTranslatable

Parameters

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

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

File

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

Class

ConfigNamesMapperTest
Tests the functionality provided by the configuration names mapper.

Namespace

Drupal\Tests\config_translation\Unit

Code

public function testHasTranslatable(array $mock_return_values, $expected) : void {
    // 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[] = isset($mock_return_values[$i]) ? [
            $config_name,
            $mock_return_values[$i],
        ] : [];
    }
    $this->configMapperManager
        ->expects($this->any())
        ->method('hasTranslatable')
        ->willReturnMap($map);
    $result = $this->configNamesMapper
        ->hasTranslatable();
    $this->assertSame($expected, $result);
}

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