Unverified Commit e3dea8c6 authored by larowlan's avatar larowlan
Browse files

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 <?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\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
/** /**
* Tests for altering configuration translation forms. * Tests for altering configuration translation forms.
* *
* @group config_translation * @group config_translation
*/ */
class ConfigTranslationFormTest extends BrowserTestBase { class ConfigTranslationFormTest extends KernelTestBase {
/** /**
* Modules to enable. * {@inheritdoc}
*
* @var array
*/ */
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. * Tests altering of the configuration translation forms.
*
* @var string
*/
protected $pluginId;
/**
* The language code of the language to use for testing.
*
* @var string
*/ */
protected $langcode; public function testConfigTranslationFormAlter() {
$this->installConfig(['config_translation_test']);
protected function setUp() { $definitions = $this->container->get('plugin.manager.config_translation.mapper')->getDefinitions();
parent::setUp(); $plugin_id = key($definitions);
$langcode = 'xx';
$definitions = \Drupal::service('plugin.manager.config_translation.mapper')->getDefinitions(); ConfigurableLanguage::create(['id' => $langcode, 'label' => 'XX'])->save();
$this->pluginId = key($definitions);
$this->langcode = 'xx'; $this->container->get('state')->set('config_translation_test_alter_form_alter', TRUE);
ConfigurableLanguage::create(['id' => $this->langcode, 'label' => 'XX'])->save();
\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');
/** $add_form = $form_builder->getForm(ConfigTranslationAddForm::class, $route_match, $plugin_id, $langcode);
* Tests altering of the configuration translation forms. $edit_form = $form_builder->getForm(ConfigTranslationEditForm::class, $route_match, $plugin_id, $langcode);
*/
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);
// Test that hook_form_BASE_FORM_ID_alter() was called for the base form ID // Test that hook_form_BASE_FORM_ID_alter() was called for the base form ID
// 'config_translation_form'. // '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