class ConfigTranslationFormTest
Same name and namespace in other branches
- 11.x core/modules/config_translation/tests/src/Kernel/ConfigTranslationFormTest.php \Drupal\Tests\config_translation\Kernel\ConfigTranslationFormTest
- 10 core/modules/config_translation/tests/src/Kernel/ConfigTranslationFormTest.php \Drupal\Tests\config_translation\Kernel\ConfigTranslationFormTest
- 8.9.x core/modules/config_translation/tests/src/Kernel/ConfigTranslationFormTest.php \Drupal\Tests\config_translation\Kernel\ConfigTranslationFormTest
Tests for altering configuration translation forms.
@group config_translation
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\config_translation\Kernel\ConfigTranslationFormTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ConfigTranslationFormTest
File
-
core/
modules/ config_translation/ tests/ src/ Kernel/ ConfigTranslationFormTest.php, line 15
Namespace
Drupal\Tests\config_translation\KernelView source
class ConfigTranslationFormTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'config_translation',
'config_translation_test',
'language',
'locale',
];
/**
* Tests altering of the configuration translation forms.
*/
public function testConfigTranslationFormAlter() {
$this->installConfig([
'config_translation_test',
]);
$definitions = $this->container
->get('plugin.manager.config_translation.mapper')
->getDefinitions();
$plugin_id = key($definitions);
$langcode = 'xx';
ConfigurableLanguage::create([
'id' => $langcode,
'label' => 'XX',
])->save();
$this->container
->get('state')
->set('config_translation_test_alter_form_alter', TRUE);
$form_builder = $this->container
->get('form_builder');
$route_match = $this->container
->get('current_route_match');
$add_form = $form_builder->getForm(ConfigTranslationAddForm::class, $route_match, $plugin_id, $langcode);
$edit_form = $form_builder->getForm(ConfigTranslationEditForm::class, $route_match, $plugin_id, $langcode);
// Test that hook_form_BASE_FORM_ID_alter() was called for the base form ID
// 'config_translation_form'.
$this->assertTrue($add_form['#base_altered']);
$this->assertTrue($edit_form['#base_altered']);
// Test that hook_form_FORM_ID_alter() was called for the form IDs
// 'config_translation_add_form' and 'config_translation_edit_form'.
$this->assertTrue($add_form['#altered']);
$this->assertTrue($edit_form['#altered']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.