Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -18,4 +18,3 @@ config_translation_test.content:
|
|||
label: 'Animals'
|
||||
sequence:
|
||||
type: label
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_translation
|
||||
- config_test
|
||||
- drupal:config_translation
|
||||
- drupal:config_test
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
services:
|
||||
config_translation_test_event_subscriber:
|
||||
class: Drupal\config_translation_test\EventSubscriber\ConfigTranslationTestSubscriber
|
||||
tags:
|
||||
- {name: event_subscriber}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation_test\EventSubscriber;
|
||||
|
||||
use Drupal\config_translation\Event\ConfigMapperPopulateEvent;
|
||||
use Drupal\config_translation\Event\ConfigTranslationEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* Adds configuration names to configuration mapper on POPULATE_MAPPER event.
|
||||
*/
|
||||
class ConfigTranslationTestSubscriber implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
return [
|
||||
ConfigTranslationEvents::POPULATE_MAPPER => [
|
||||
['addConfigNames'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reacts to the populating of a configuration mapper.
|
||||
*
|
||||
* @param \Drupal\config_translation\Event\ConfigMapperPopulateEvent $event
|
||||
* The configuration mapper event.
|
||||
*/
|
||||
public function addConfigNames(ConfigMapperPopulateEvent $event) {
|
||||
$mapper = $event->getMapper();
|
||||
if ($mapper->getBaseRouteName() === 'system.site_information_settings' && $mapper->getLangcode() === 'en') {
|
||||
$mapper->addConfigName('config_translation_test.content');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationCacheTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = [
|
||||
'block',
|
||||
'config_translation',
|
||||
'config_translation_test',
|
||||
'contact',
|
||||
'contact_test',
|
||||
'contextual',
|
||||
'entity_test',
|
||||
'field_test',
|
||||
'field_ui',
|
||||
'filter',
|
||||
'filter_test',
|
||||
'node',
|
||||
'views',
|
||||
'views_ui',
|
||||
];
|
||||
|
||||
/**
|
||||
* Languages to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* Administrator user for tests.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
/**
|
||||
* Translator user for tests.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $translatorUser;
|
||||
|
||||
/**
|
||||
* String translation storage object.
|
||||
*
|
||||
* @var \Drupal\locale\StringStorageInterface
|
||||
*/
|
||||
protected $localeStorage;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$translator_permissions = [
|
||||
'translate configuration',
|
||||
];
|
||||
|
||||
/** @var \Drupal\filter\FilterFormatInterface $filter_test_format */
|
||||
$filter_test_format = FilterFormat::load('filter_test');
|
||||
/** @var \Drupal\filter\FilterFormatInterface $filtered_html_format */
|
||||
$filtered_html_format = FilterFormat::load('filtered_html');
|
||||
/** @var \Drupal\filter\FilterFormatInterface $full_html_format */
|
||||
$full_html_format = FilterFormat::load('full_html');
|
||||
|
||||
$admin_permissions = array_merge($translator_permissions, [
|
||||
'administer languages',
|
||||
'administer site configuration',
|
||||
'link to any page',
|
||||
'administer contact forms',
|
||||
'administer filters',
|
||||
$filtered_html_format->getPermissionName(),
|
||||
$full_html_format->getPermissionName(),
|
||||
$filter_test_format->getPermissionName(),
|
||||
'access site-wide contact form',
|
||||
'access contextual links',
|
||||
'administer account settings',
|
||||
'administer themes',
|
||||
'bypass node access',
|
||||
'administer content types',
|
||||
'translate interface',
|
||||
'administer entity_test fields',
|
||||
]);
|
||||
// Create and login user.
|
||||
$this->translatorUser = $this->drupalCreateUser($translator_permissions);
|
||||
$this->adminUser = $this->drupalCreateUser($admin_permissions);
|
||||
|
||||
// Add languages.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the translation of field and field storage configuration.
|
||||
*/
|
||||
public function testFieldConfigTranslation() {
|
||||
// Add a test field which has a translatable field setting and a
|
||||
// translatable field storage setting.
|
||||
$field_name = strtolower($this->randomMachineName());
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'test_field',
|
||||
]);
|
||||
|
||||
$translatable_storage_setting = $this->randomString();
|
||||
$field_storage->setSetting('translatable_storage_setting', $translatable_storage_setting);
|
||||
$field_storage->save();
|
||||
|
||||
$bundle = strtolower($this->randomMachineName());
|
||||
entity_test_create_bundle($bundle);
|
||||
$field = FieldConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => $bundle,
|
||||
]);
|
||||
|
||||
$translatable_field_setting = $this->randomString();
|
||||
$field->setSetting('translatable_field_setting', $translatable_field_setting);
|
||||
$field->save();
|
||||
|
||||
$this->drupalLogin($this->translatorUser);
|
||||
|
||||
$this->drupalGet("/entity_test/structure/$bundle/fields/entity_test.$bundle.$field_name/translate");
|
||||
$this->clickLink('Add');
|
||||
|
||||
$this->assertText('Translatable field setting');
|
||||
$this->assertEscaped($translatable_field_setting);
|
||||
$this->assertText('Translatable storage setting');
|
||||
$this->assertEscaped($translatable_storage_setting);
|
||||
|
||||
// Add translation for label.
|
||||
$field_label_fr = $this->randomString();
|
||||
$edit = [
|
||||
"translation[config_names][field.field.entity_test.$bundle.$field_name][label]" => $field_label_fr,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, 'Save translation');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Check if the translated label appears.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalGet("/fr/entity_test/structure/$bundle/fields");
|
||||
$this->assertEscaped($field_label_fr);
|
||||
|
||||
// Clear cache on French version and check for translated label.
|
||||
$this->drupalPostForm('/fr/admin/config/development/performance', [], 'Clear all caches');
|
||||
$this->drupalGet("/fr/entity_test/structure/$bundle/fields");
|
||||
// Check if the translation is still there.
|
||||
$this->assertEscaped($field_label_fr);
|
||||
|
||||
// Clear cache on default version and check for translated label.
|
||||
$this->drupalPostForm('/admin/config/development/performance', [], 'Clear all caches');
|
||||
$this->drupalGet("/fr/entity_test/structure/$bundle/fields");
|
||||
// Check if the translation is still there.
|
||||
$this->assertEscaped($field_label_fr);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ class ConfigTranslationDateFormatUiTest extends BrowserTestBase {
|
|||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
'system'
|
||||
'system',
|
||||
];
|
||||
|
||||
protected function setUp() {
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests for altering configuration translation forms.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationFormTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['config_translation', 'config_translation_test', 'editor'];
|
||||
|
||||
/**
|
||||
* The plugin ID of the mapper to test.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pluginId;
|
||||
|
||||
/**
|
||||
* The language code of the language to use for testing.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $langcode;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$definitions = \Drupal::service('plugin.manager.config_translation.mapper')->getDefinitions();
|
||||
$this->pluginId = key($definitions);
|
||||
|
||||
$this->langcode = 'xx';
|
||||
ConfigurableLanguage::create(['id' => $this->langcode, 'label' => 'XX'])->save();
|
||||
|
||||
\Drupal::state()->set('config_translation_test_alter_form_alter', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
// 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']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\FunctionalTests\Installer\InstallerTestBase;
|
||||
|
||||
/**
|
||||
* Installs the config translation module on a site installed in non english.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationInstallTest extends InstallerTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $langcode = 'eo';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $profile = 'standard';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpLanguage() {
|
||||
// Place custom local translations in the translations directory.
|
||||
mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
|
||||
file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.eo.po', $this->getPo('eo'));
|
||||
|
||||
parent::setUpLanguage();
|
||||
|
||||
$this->translations['Save and continue'] = 'Save and continue eo';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string for the test .po file.
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
* @return string
|
||||
* Contents for the test .po file.
|
||||
*/
|
||||
protected function getPo($langcode) {
|
||||
return <<<ENDPO
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgid "Save and continue"
|
||||
msgstr "Save and continue $langcode"
|
||||
|
||||
msgid "Anonymous"
|
||||
msgstr "Anonymous $langcode"
|
||||
|
||||
msgid "Language"
|
||||
msgstr "Language $langcode"
|
||||
ENDPO;
|
||||
}
|
||||
|
||||
public function testConfigTranslation() {
|
||||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'en'], t('Add custom language'));
|
||||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'fr'], t('Add custom language'));
|
||||
|
||||
$edit = [
|
||||
'modules[config_translation][enable]' => TRUE,
|
||||
];
|
||||
$this->drupalPostForm('admin/modules', $edit, t('Install'));
|
||||
|
||||
$this->drupalGet('/admin/structure/types/manage/article/fields');
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\block_content\Entity\BlockContentType;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
|
@ -80,6 +79,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
|
||||
->save();
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
protected function doBlockListTest() {
|
||||
// Add a test block, any block will do.
|
||||
// Set the machine name so the translate link can be built later.
|
||||
$id = Unicode::strtolower($this->randomMachineName(16));
|
||||
$id = mb_strtolower($this->randomMachineName(16));
|
||||
$this->drupalPlaceBlock('system_powered_by_block', ['id' => $id]);
|
||||
|
||||
// Get the Block listing.
|
||||
|
@ -116,7 +116,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
// this does not test more than necessary.
|
||||
$this->drupalGet('admin/structure/menu/add');
|
||||
// Lowercase the machine name.
|
||||
$menu_name = Unicode::strtolower($this->randomMachineName(16));
|
||||
$menu_name = mb_strtolower($this->randomMachineName(16));
|
||||
$label = $this->randomMachineName(16);
|
||||
$edit = [
|
||||
'id' => $menu_name,
|
||||
|
@ -164,7 +164,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
$vocabulary = Vocabulary::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
'description' => $this->randomMachineName(),
|
||||
'vid' => Unicode::strtolower($this->randomMachineName()),
|
||||
'vid' => mb_strtolower($this->randomMachineName()),
|
||||
]);
|
||||
$vocabulary->save();
|
||||
|
||||
|
@ -187,9 +187,9 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
// Create a test custom block type to decouple looking for translate
|
||||
// operations link so this does not test more than necessary.
|
||||
$block_content_type = BlockContentType::create([
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'id' => mb_strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomMachineName(),
|
||||
'revision' => FALSE
|
||||
'revision' => FALSE,
|
||||
]);
|
||||
$block_content_type->save();
|
||||
|
||||
|
@ -212,7 +212,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
// Create a test contact form to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$contact_form = ContactForm::create([
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'id' => mb_strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomMachineName(),
|
||||
]);
|
||||
$contact_form->save();
|
||||
|
@ -236,7 +236,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
// Create a test content type to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$content_type = $this->drupalCreateContentType([
|
||||
'type' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'type' => mb_strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
|
||||
|
@ -259,7 +259,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
// Create a test format to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$filter_format = FilterFormat::create([
|
||||
'format' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'format' => mb_strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
$filter_format->save();
|
||||
|
@ -283,7 +283,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
// Create a test shortcut to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$shortcut = ShortcutSet::create([
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'id' => mb_strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomString(),
|
||||
]);
|
||||
$shortcut->save();
|
||||
|
@ -306,7 +306,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
public function doUserRoleListTest() {
|
||||
// Create a test role to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$role_id = Unicode::strtolower($this->randomMachineName(16));
|
||||
$role_id = mb_strtolower($this->randomMachineName(16));
|
||||
$this->drupalCreateRole([], $role_id);
|
||||
|
||||
// Get the role listing.
|
||||
|
@ -387,7 +387,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
public function doFieldListTest() {
|
||||
// Create a base content type.
|
||||
$content_type = $this->drupalCreateContentType([
|
||||
'type' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'type' => mb_strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
|
||||
|
@ -395,7 +395,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
|||
$block_content_type = BlockContentType::create([
|
||||
'id' => 'basic',
|
||||
'label' => 'Basic',
|
||||
'revision' => FALSE
|
||||
'revision' => FALSE,
|
||||
]);
|
||||
$block_content_type->save();
|
||||
$field = FieldConfig::create([
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationOverviewTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = [
|
||||
'block',
|
||||
'config_test',
|
||||
'config_translation',
|
||||
'config_translation_test',
|
||||
'contact',
|
||||
'contextual',
|
||||
'entity_test_operation',
|
||||
'views',
|
||||
'views_ui',
|
||||
];
|
||||
|
||||
/**
|
||||
* Languages to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* String translation storage object.
|
||||
*
|
||||
* @var \Drupal\locale\StringStorageInterface
|
||||
*/
|
||||
protected $localeStorage;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$permissions = [
|
||||
'translate configuration',
|
||||
'administer languages',
|
||||
'administer site configuration',
|
||||
'administer contact forms',
|
||||
'access site-wide contact form',
|
||||
'access contextual links',
|
||||
'administer views',
|
||||
];
|
||||
// Create and log in user.
|
||||
$this->drupalLogin($this->drupalCreateUser($permissions));
|
||||
|
||||
// Add languages.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
$this->localeStorage = $this->container->get('locale.storage');
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the config translation mapper page.
|
||||
*/
|
||||
public function testMapperListPage() {
|
||||
$this->drupalGet('admin/config/regional/config-translation');
|
||||
$this->assertLinkByHref('admin/config/regional/config-translation/config_test');
|
||||
$this->assertLinkByHref('admin/config/people/accounts/translate');
|
||||
// Make sure there is only a single operation for each dropbutton, either
|
||||
// 'List' or 'Translate'.
|
||||
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
|
||||
$this->assertIdentical(1, count($dropbutton->findAll('xpath', 'li')));
|
||||
$this->assertTrue(($dropbutton->getText() === 'Translate') || ($dropbutton->getText() === 'List'));
|
||||
}
|
||||
|
||||
$labels = [
|
||||
'&$nxd~i0',
|
||||
'some "label" with quotes',
|
||||
$this->randomString(),
|
||||
];
|
||||
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('config_test');
|
||||
foreach ($labels as $label) {
|
||||
$test_entity = $storage->create([
|
||||
'id' => $this->randomMachineName(),
|
||||
'label' => $label,
|
||||
]);
|
||||
$test_entity->save();
|
||||
|
||||
$base_url = 'admin/structure/config_test/manage/' . $test_entity->id();
|
||||
$this->drupalGet('admin/config/regional/config-translation/config_test');
|
||||
$this->assertLinkByHref($base_url . '/translate');
|
||||
$this->assertEscaped($test_entity->label());
|
||||
|
||||
// Make sure there is only a single 'Translate' operation for each
|
||||
// dropbutton.
|
||||
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
|
||||
$this->assertIdentical(1, count($dropbutton->findAll('xpath', 'li')));
|
||||
$this->assertIdentical('Translate', $dropbutton->getText());
|
||||
}
|
||||
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId());
|
||||
$this->drupalGet($base_url . '/translate');
|
||||
|
||||
$title = $test_entity->label() . ' ' . $entity_type->getLowercaseLabel();
|
||||
$title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
|
||||
$this->assertRaw($title);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
|
||||
$this->drupalGet($base_url);
|
||||
$this->assertLink(t('Translate @title', ['@title' => $entity_type->getLowercaseLabel()]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests availability of hidden entities in the translation overview.
|
||||
*/
|
||||
public function testHiddenEntities() {
|
||||
// Hidden languages are only available to translate through the
|
||||
// configuration translation listings.
|
||||
$this->drupalGet('admin/config/regional/config-translation/configurable_language');
|
||||
$this->assertText('Not applicable');
|
||||
$this->assertLinkByHref('admin/config/regional/language/edit/zxx/translate');
|
||||
$this->assertText('Not specified');
|
||||
$this->assertLinkByHref('admin/config/regional/language/edit/und/translate');
|
||||
|
||||
// Hidden date formats are only available to translate through the
|
||||
// configuration translation listings. Test a couple of them.
|
||||
$this->drupalGet('admin/config/regional/config-translation/date_format');
|
||||
$this->assertText('HTML Date');
|
||||
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_date/translate');
|
||||
$this->assertText('HTML Year');
|
||||
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_year/translate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that overrides do not affect listing screens.
|
||||
*/
|
||||
public function testListingPageWithOverrides() {
|
||||
$original_label = 'Default';
|
||||
$overridden_label = 'Overridden label';
|
||||
|
||||
$config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
|
||||
|
||||
// Set up an override.
|
||||
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [
|
||||
'value' => $overridden_label,
|
||||
'required' => TRUE,
|
||||
];
|
||||
$this->writeSettings($settings);
|
||||
|
||||
// Test that the overridden label is loaded with the entity.
|
||||
$this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label);
|
||||
|
||||
// Test that the original label on the listing page is intact.
|
||||
$this->drupalGet('admin/config/regional/config-translation/config_test');
|
||||
$this->assertText($original_label);
|
||||
$this->assertNoText($overridden_label);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Verifies theme configuration translation settings.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationUiThemeTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['config_translation', 'config_translation_test'];
|
||||
|
||||
/**
|
||||
* Languages to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* Administrator user for tests.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$admin_permissions = [
|
||||
'administer themes',
|
||||
'administer languages',
|
||||
'administer site configuration',
|
||||
'translate configuration',
|
||||
];
|
||||
// Create and log in user.
|
||||
$this->adminUser = $this->drupalCreateUser($admin_permissions);
|
||||
|
||||
// Add languages.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that theme provided *.config_translation.yml files are found.
|
||||
*/
|
||||
public function testThemeDiscovery() {
|
||||
// Install the test theme and rebuild routes.
|
||||
$theme = 'config_translation_test_theme';
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
$this->drupalGet('admin/appearance');
|
||||
$elements = $this->xpath('//a[normalize-space()=:label and contains(@href, :theme)]', [
|
||||
':label' => 'Install and set as default',
|
||||
':theme' => $theme,
|
||||
]);
|
||||
$this->drupalGet($GLOBALS['base_root'] . $elements[0]->getAttribute('href'), ['external' => TRUE]);
|
||||
|
||||
$translation_base_url = 'admin/config/development/performance/translate';
|
||||
$this->drupalGet($translation_base_url);
|
||||
$this->assertResponse(200);
|
||||
$this->assertLinkByHref("$translation_base_url/fr/add");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\Tests\views_ui\Functional\UITestBase;
|
||||
|
||||
/**
|
||||
* Visit view list and test if translate is available.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationViewListUiTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['node', 'test_view'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['config_translation', 'views_ui'];
|
||||
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$permissions = [
|
||||
'administer views',
|
||||
'translate configuration',
|
||||
];
|
||||
|
||||
// Create and log in user.
|
||||
$this->drupalLogin($this->drupalCreateUser($permissions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests views_ui list to see if translate link is added to operations.
|
||||
*/
|
||||
public function testTranslateOperationInViewListUi() {
|
||||
// Views UI List 'admin/structure/views'.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$translate_link = 'admin/structure/views/view/test_view/translate';
|
||||
// Test if the link to translate the test_view is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
|
||||
// Test that the 'Edit' tab appears.
|
||||
$this->assertLinkByHref('admin/structure/views/view/test_view');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationUiTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'config_translation',
|
||||
'contextual',
|
||||
'node',
|
||||
'views',
|
||||
'views_ui',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests that contextual link related to views.
|
||||
*/
|
||||
public function testViewContextualLink() {
|
||||
$user = $this->drupalCreateUser([
|
||||
'translate configuration',
|
||||
'access contextual links',
|
||||
]);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
$this->drupalGet('node');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual-links');
|
||||
$link = $contextualLinks->findLink('Translate view');
|
||||
$this->assertNotNull($link, 'Translate view contextual link added.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel;
|
||||
|
||||
use Drupal\Core\Routing\RouteMatch;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Tests config mapper.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigMapperTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'config_translation',
|
||||
'config_translation_test',
|
||||
'language',
|
||||
'locale',
|
||||
'system',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests adding config names to mapper.
|
||||
*/
|
||||
public function testAddingConfigNames() {
|
||||
// Get a config names mapper.
|
||||
$mappers = \Drupal::service('plugin.manager.config_translation.mapper')->getMappers();
|
||||
$mapper = $mappers['system.site_information_settings'];
|
||||
|
||||
// Test that it doesn't contain a config name from config_translation_test.
|
||||
$config_names = $mapper->getConfigNames();
|
||||
$this->assertNotContains('config_translation_test.content', $config_names);
|
||||
|
||||
// Call populateFromRouteMatch() to dispatch the "config mapper populate"
|
||||
// event.
|
||||
$mapper->populateFromRouteMatch(new RouteMatch('test', new Route('/')));
|
||||
|
||||
// Test that it contains the new config name from config_translation_test.
|
||||
$config_names = $mapper->getConfigNames();
|
||||
$this->assertContains('config_translation_test.content', $config_names);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,17 +8,23 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Upgrade i18n maintenance variables to system.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nSystemMaintenanceTest extends MigrateDrupal6TestBase {
|
||||
class MigrateSystemMaintenanceTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
public static $modules = ['language', 'config_translation'];
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_i18n_system_maintenance');
|
||||
$this->executeMigration('d6_system_maintenance_translation');
|
||||
}
|
||||
|
||||
/**
|
|
@ -8,17 +8,23 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Upgrade i18n_strings site variables to system.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nSystemSiteTest extends MigrateDrupal6TestBase {
|
||||
class MigrateSystemSiteTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
public static $modules = ['language', 'config_translation'];
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_i18n_system_site');
|
||||
$this->executeMigration('d6_system_site_translation');
|
||||
}
|
||||
|
||||
/**
|
|
@ -9,12 +9,19 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Upgrade i18n variables to user.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nUserConfigsTest extends MigrateDrupal6TestBase {
|
||||
class MigrateUserConfigsTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
public static $modules = ['language', 'locale', 'config_translation'];
|
||||
public static $modules = [
|
||||
'language',
|
||||
'locale',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -23,7 +30,7 @@ class MigrateI18nUserConfigsTest extends MigrateDrupal6TestBase {
|
|||
parent::setUp();
|
||||
$this->installSchema('locale',
|
||||
['locales_source', 'locales_target', 'locales_location']);
|
||||
$this->executeMigrations(['d6_i18n_user_mail', 'd6_i18n_user_settings']);
|
||||
$this->executeMigrations(['d6_user_mail_translation', 'd6_user_settings_translation']);
|
||||
}
|
||||
|
||||
/**
|
|
@ -8,13 +8,21 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Tests the user profile field instance migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
|
||||
class MigrateUserProfileFieldInstanceTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['config_translation', 'locale', 'language', 'field'];
|
||||
public static $modules = [
|
||||
'config_translation',
|
||||
'locale',
|
||||
'language',
|
||||
'field',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests migration of translated user profile fields.
|
||||
|
@ -23,11 +31,11 @@ class MigrateI18nUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
|
|||
$this->executeMigrations([
|
||||
'user_profile_field',
|
||||
'user_profile_field_instance',
|
||||
'd6_i18n_user_profile_field_instance',
|
||||
'd6_user_profile_field_instance_translation',
|
||||
]);
|
||||
$language_manager = $this->container->get('language_manager');
|
||||
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_love_migrations');
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_really_really_love_mig');
|
||||
$this->assertSame("J'aime les migrations", $config_translation->get('label'));
|
||||
$this->assertSame("Si vous cochez cette case, vous aimez les migrations.", $config_translation->get('description'));
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migrations of i18n maintenance variable.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateSystemMaintenanceTranslationTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_system_maintenance_translation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migrations of i18n maintenance variable.
|
||||
*/
|
||||
public function testSystemMaintenance() {
|
||||
$config = \Drupal::service('language_manager')->getLanguageConfigOverride('is', 'system.maintenance');
|
||||
$this->assertSame('is - This is a custom maintenance mode message.', $config->get('message'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Migrate multilingual site variables.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateSystemSiteTranslationTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_system_site_translation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of system (site) variables to system.site.yml.
|
||||
*/
|
||||
public function testSystemSite() {
|
||||
$language_manager = \Drupal::service('language_manager');
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'system.site');
|
||||
$this->assertSame('The Site Name', $config_translation->get('name'));
|
||||
$this->assertSame('fr - The Slogan', $config_translation->get('slogan'));
|
||||
$this->assertSame('node', $config_translation->get('page.403'));
|
||||
$this->assertSame('node', $config_translation->get('page.404'));
|
||||
$this->assertSame('node', $config_translation->get('page.front'));
|
||||
$this->assertSame(NULL, $config_translation->get('admin_compact_mode'));
|
||||
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('is', 'system.site');
|
||||
$this->assertSame('is - The Site Name', $config_translation->get('name'));
|
||||
$this->assertSame('is - The Slogan', $config_translation->get('slogan'));
|
||||
$this->assertSame('node/1', $config_translation->get('page.403'));
|
||||
$this->assertSame('node/6', $config_translation->get('page.404'));
|
||||
$this->assertSame('node/4', $config_translation->get('page.front'));
|
||||
$this->assertNULL($config_translation->get('admin_compact_mode'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Test migration of i18n user variables.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateUserConfigsTranslationTest extends MigrateDrupal7TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'language',
|
||||
'locale',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('locale', [
|
||||
'locales_source',
|
||||
'locales_target',
|
||||
'locales_location',
|
||||
]);
|
||||
$this->executeMigrations([
|
||||
'd7_user_mail_translation',
|
||||
'd7_user_settings_translation',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of i18n user variables to user.mail and user.settings.
|
||||
*/
|
||||
public function testUserConfig() {
|
||||
// Tests migration of i18n user variables to user.mail.yml.
|
||||
$language_manager = \Drupal::service('language_manager');
|
||||
$config = $language_manager->getLanguageConfigOverride('is', 'user.mail');
|
||||
$this->assertSame('is - Are you sure?', $config->get('cancel_confirm.subject'));
|
||||
$this->assertSame('is - A little birdie said you wanted to cancel your account.', $config->get('cancel_confirm.body'));
|
||||
$this->assertSame('is - Fix your password', $config->get('password_reset.subject'));
|
||||
$this->assertSame("is - Nope! You're locked out forever.", $config->get('password_reset.body'));
|
||||
$this->assertSame('is - Gawd made you an account', $config->get('register_admin_created.subject'));
|
||||
$this->assertSame("is - ...and she could take it away.\r\n[site:name], [site:url]", $config->get('register_admin_created.body'));
|
||||
$this->assertSame('is - Welcome!', $config->get('register_no_approval_required.subject'));
|
||||
$this->assertSame('is - You can now log in if you can figure out how to use Drupal!', $config->get('register_no_approval_required.body'));
|
||||
$this->assertSame('is - Soon...', $config->get('register_pending_approval.subject'));
|
||||
$this->assertSame('is - ...you will join our Circle. Let the Drupal flow through you.', $config->get('register_pending_approval.body'));
|
||||
$this->assertSame('is - Your account is approved!', $config->get('status_activated.subject'));
|
||||
$this->assertSame('is - Your account was activated, and there was much rejoicing.', $config->get('status_activated.body'));
|
||||
$this->assertSame('is - BEGONE!', $config->get('status_blocked.subject'));
|
||||
$this->assertSame('is - You no longer please the robot overlords. Go to your room and chill out.', $config->get('status_blocked.body'));
|
||||
$this->assertSame('is - So long, bub', $config->get('status_canceled.subject'));
|
||||
$this->assertSame('is - The gates of Drupal are closed to you. Now you will work in the salt mines.', $config->get('status_canceled.body'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get());
|
||||
|
||||
// Tests migration of i18n user variables to user.settings.yml.
|
||||
$config = $language_manager->getLanguageConfigOverride('is', 'user.settings');
|
||||
$this->assertSame('is - anonymous', $config->get('anonymous'));
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
|||
*
|
||||
* @covers \Drupal\config_translation\Plugin\migrate\source\d6\I18nProfileField
|
||||
* @group migrate_drupal
|
||||
* @group legacy
|
||||
*/
|
||||
class I18nProfileFieldTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
|
@ -41,8 +42,8 @@ class I18nProfileFieldTest extends MigrateSqlSourceTestBase {
|
|||
'lid' => 11,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'explanation'
|
||||
]
|
||||
'property' => 'explanation',
|
||||
],
|
||||
],
|
||||
'locales_target' => [
|
||||
[
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests the i18nProfileField source plugin.
|
||||
*
|
||||
* @covers \Drupal\config_translation\Plugin\migrate\source\d6\ProfileFieldTranslation
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class ProfileFieldTranslationTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['config_translation', 'migrate_drupal', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$test = [];
|
||||
$test[0]['source_data'] = [
|
||||
'profile_fields' => [
|
||||
[
|
||||
'fid' => 42,
|
||||
'title' => 'I love migrations',
|
||||
'name' => 'profile_love_migrations',
|
||||
],
|
||||
],
|
||||
'i18n_strings' => [
|
||||
[
|
||||
'lid' => 10,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'title',
|
||||
],
|
||||
[
|
||||
'lid' => 11,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'explanation',
|
||||
],
|
||||
],
|
||||
'locales_target' => [
|
||||
[
|
||||
'lid' => 10,
|
||||
'translation' => "J'aime les migrations.",
|
||||
'language' => 'fr',
|
||||
],
|
||||
[
|
||||
'lid' => 11,
|
||||
'translation' => 'Si vous cochez cette case, vous aimez les migrations.',
|
||||
'language' => 'fr',
|
||||
],
|
||||
],
|
||||
];
|
||||
$test[0]['expected_results'] = [
|
||||
[
|
||||
'property' => 'title',
|
||||
'translation' => "J'aime les migrations.",
|
||||
'language' => 'fr',
|
||||
'fid' => '42',
|
||||
'name' => 'profile_love_migrations',
|
||||
],
|
||||
[
|
||||
'property' => 'explanation',
|
||||
'translation' => 'Si vous cochez cette case, vous aimez les migrations.',
|
||||
'language' => 'fr',
|
||||
'fid' => '42',
|
||||
'name' => 'profile_love_migrations',
|
||||
],
|
||||
];
|
||||
return $test;
|
||||
}
|
||||
|
||||
}
|
|
@ -45,10 +45,17 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
/**
|
||||
* The mocked language manager.
|
||||
*
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface $language_manager|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* The mocked event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
protected function setUp() {
|
||||
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
|
||||
|
@ -79,6 +86,8 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
|
||||
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
|
||||
$this->configEntityMapper = new ConfigEntityMapper(
|
||||
'configurable_language',
|
||||
$definition,
|
||||
|
@ -89,7 +98,8 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
$this->routeProvider,
|
||||
$this->getStringTranslationStub(),
|
||||
$this->entityManager,
|
||||
$this->languageManager
|
||||
$this->languageManager,
|
||||
$this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,13 @@ class ConfigFieldMapperTest extends UnitTestCase {
|
|||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* The mocked event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -54,6 +61,8 @@ class ConfigFieldMapperTest extends UnitTestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
|
||||
$this->configFieldMapper = new ConfigFieldMapper(
|
||||
'node_fields',
|
||||
$definition,
|
||||
|
@ -64,7 +73,8 @@ class ConfigFieldMapperTest extends UnitTestCase {
|
|||
$this->getMock('Drupal\Core\Routing\RouteProviderInterface'),
|
||||
$this->getStringTranslationStub(),
|
||||
$this->entityManager,
|
||||
$this->getMock('Drupal\Core\Language\LanguageManagerInterface')
|
||||
$this->getMock('Drupal\Core\Language\LanguageManagerInterface'),
|
||||
$this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,44 +88,52 @@ class ConfigMapperManagerTest extends UnitTestCase {
|
|||
[$this->getElement(['aaa' => 'bbb']), FALSE],
|
||||
[$this->getElement(['translatable' => FALSE]), FALSE],
|
||||
[$this->getElement(['translatable' => TRUE]), TRUE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement([]),
|
||||
]), FALSE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]), TRUE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]), FALSE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]), TRUE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
[$this->getNestedElement([$this->getElement([])]), FALSE],
|
||||
[$this->getNestedElement([$this->getElement(['translatable' => TRUE])]), TRUE],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
FALSE,
|
||||
],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['iii' => 'jjj']),
|
||||
]),
|
||||
]), FALSE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]),
|
||||
]), TRUE],
|
||||
TRUE,
|
||||
],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['iii' => 'jjj']),
|
||||
]),
|
||||
]),
|
||||
FALSE,
|
||||
],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]),
|
||||
]),
|
||||
TRUE,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -84,10 +84,17 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
|||
/**
|
||||
* The mocked language manager.
|
||||
*
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface $language_manager|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* The mocked event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
protected function setUp() {
|
||||
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
|
||||
|
||||
|
@ -122,6 +129,8 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
|||
|
||||
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
|
||||
$this->configNamesMapper = new TestConfigNamesMapper(
|
||||
'system.site_information_settings',
|
||||
$this->pluginDefinition,
|
||||
|
@ -131,7 +140,8 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
|||
$this->configMapperManager,
|
||||
$this->routeProvider,
|
||||
$this->getStringTranslationStub(),
|
||||
$this->languageManager
|
||||
$this->languageManager,
|
||||
$this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue