function ConfigNamesMapperTest::testPopulateFromRouteMatch
Same name in other branches
- 9 core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest::testPopulateFromRouteMatch()
- 8.9.x core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest::testPopulateFromRouteMatch()
- 11.x core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php \Drupal\Tests\config_translation\Unit\ConfigNamesMapperTest::testPopulateFromRouteMatch()
Tests ConfigNamesMapper::populateFromRouteMatch().
File
-
core/
modules/ config_translation/ tests/ src/ Unit/ ConfigNamesMapperTest.php, line 385
Class
- ConfigNamesMapperTest
- Tests the functionality provided by the configuration names mapper.
Namespace
Drupal\Tests\config_translation\UnitCode
public function testPopulateFromRouteMatch() : void {
// Make sure the language code is not set initially.
$this->assertNull($this->configNamesMapper
->getInternalLangcode());
// Test that an empty request does not set the language code.
$route_match = new RouteMatch('example', new Route('/test/{langcode}'));
$this->configNamesMapper
->populateFromRouteMatch($route_match);
$this->assertNull($this->configNamesMapper
->getInternalLangcode());
// Test that a request with a 'langcode' attribute sets the language code.
$route_match = new RouteMatch('example', new Route('/test/{langcode}'), [
'langcode' => 'xx',
]);
$this->configNamesMapper
->populateFromRouteMatch($route_match);
$this->assertSame('xx', $this->configNamesMapper
->getInternalLangcode());
// Test that the language code gets unset with the wrong request.
$route_match = new RouteMatch('example', new Route('/test/{langcode}'));
$this->configNamesMapper
->populateFromRouteMatch($route_match);
$this->assertNull($this->configNamesMapper
->getInternalLangcode());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.