Commit e3dea8c6 authored by larowlan's avatar larowlan

Issue #3046382 by vadim.hirbu, claudiu.cristea, Lendude: Convert...

Issue #3046382 by vadim.hirbu, claudiu.cristea, Lendude: Convert ConfigTranslationFormTest into a Kernel test
parent 01f76ced
<?php
namespace Drupal\Tests\config_translation\Functional;
namespace Drupal\Tests\config_translation\Kernel;
use Drupal\config_translation\Form\ConfigTranslationAddForm;
use Drupal\config_translation\Form\ConfigTranslationEditForm;
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
/**
* Tests for altering configuration translation forms.
*
* @group config_translation
*/
class ConfigTranslationFormTest extends BrowserTestBase {
class ConfigTranslationFormTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['config_translation', 'config_translation_test', 'editor'];
protected static $modules = [
'config_translation',
'config_translation_test',
'language',
'locale',
];
/**
* The plugin ID of the mapper to test.
*
* @var string
*/
protected $pluginId;
/**
* The language code of the language to use for testing.
*
* @var string
* Tests altering of the configuration translation forms.
*/
protected $langcode;
public function testConfigTranslationFormAlter() {
$this->installConfig(['config_translation_test']);
protected function setUp() {
parent::setUp();
$definitions = $this->container->get('plugin.manager.config_translation.mapper')->getDefinitions();
$plugin_id = key($definitions);
$langcode = 'xx';
$definitions = \Drupal::service('plugin.manager.config_translation.mapper')->getDefinitions();
$this->pluginId = key($definitions);
ConfigurableLanguage::create(['id' => $langcode, 'label' => 'XX'])->save();
$this->langcode = 'xx';
ConfigurableLanguage::create(['id' => $this->langcode, 'label' => 'XX'])->save();
$this->container->get('state')->set('config_translation_test_alter_form_alter', TRUE);
\Drupal::state()->set('config_translation_test_alter_form_alter', TRUE);
}
$form_builder = $this->container->get('form_builder');
$route_match = $this->container->get('current_route_match');
/**
* Tests altering of the configuration translation forms.
*/
public function testConfigTranslationFormAlter() {
$form_builder = \Drupal::formBuilder();
$add_form = $form_builder->getForm('Drupal\config_translation\Form\ConfigTranslationAddForm', \Drupal::routeMatch(), $this->pluginId, $this->langcode);
$edit_form = $form_builder->getForm('Drupal\config_translation\Form\ConfigTranslationEditForm', \Drupal::routeMatch(), $this->pluginId, $this->langcode);
$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'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment