updated core to 8.6.1 via composer
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Language admin behavior.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
(function($, Drupal) {
|
||||
/**
|
||||
* Makes language negotiation inherit user interface negotiation.
|
||||
*
|
||||
@@ -21,19 +21,24 @@
|
||||
const $checkbox = $(checkbox);
|
||||
// Get the language detection type such as Interface text language
|
||||
// detection or Content language detection.
|
||||
$checkbox.closest('.table-language-group')
|
||||
$checkbox
|
||||
.closest('.table-language-group')
|
||||
.find('table, .tabledrag-toggle-weight')
|
||||
.toggle($checkbox.prop('checked'));
|
||||
}
|
||||
|
||||
// Bind hide/show and rearrange customization checkboxes.
|
||||
$configForm.once('negotiation-language-admin-bind').on('change', inputSelector, (event) => {
|
||||
toggleTable(event.target);
|
||||
});
|
||||
$configForm
|
||||
.once('negotiation-language-admin-bind')
|
||||
.on('change', inputSelector, event => {
|
||||
toggleTable(event.target);
|
||||
});
|
||||
// Initially, hide language detection types that are not customized.
|
||||
$configForm.find(`${inputSelector}:not(:checked)`).each((index, element) => {
|
||||
toggleTable(element);
|
||||
});
|
||||
$configForm
|
||||
.find(`${inputSelector}:not(:checked)`)
|
||||
.each((index, element) => {
|
||||
toggleTable(element);
|
||||
});
|
||||
},
|
||||
};
|
||||
}(jQuery, Drupal));
|
||||
})(jQuery, Drupal);
|
||||
|
||||
@@ -15,7 +15,6 @@ use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\language\ConfigurableLanguageInterface;
|
||||
use Drupal\language\Entity\ContentLanguageSettings;
|
||||
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI;
|
||||
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
|
||||
@@ -346,38 +345,6 @@ function language_modules_uninstalled($modules) {
|
||||
language_modules_installed($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_insert() for 'configurable_language'.
|
||||
*/
|
||||
function language_configurable_language_insert(ConfigurableLanguageInterface $language) {
|
||||
if ($language->isLocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add language to the list of language domains.
|
||||
$config = \Drupal::configFactory()->getEditable('language.negotiation');
|
||||
$domains = $config->get('url.domains');
|
||||
$domains[$language->id()] = '';
|
||||
$config->set('url.domains', $domains)->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
|
||||
*/
|
||||
function language_configurable_language_delete(ConfigurableLanguageInterface $language) {
|
||||
// Remove language from language prefix list.
|
||||
$config = \Drupal::configFactory()->getEditable('language.negotiation');
|
||||
$prefixes = $config->get('url.prefixes');
|
||||
unset($prefixes[$language->id()]);
|
||||
$config->set('url.prefixes', $prefixes)->save();
|
||||
|
||||
// Remove language from language domain list.
|
||||
$config = \Drupal::configFactory()->getEditable('language.negotiation');
|
||||
$domains = $config->get('url.domains');
|
||||
unset($domains[$language->id()]);
|
||||
$config->set('url.domains', $domains)->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for block templates.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
id: d6_language_content_menu_settings
|
||||
label: Drupal 6 language content menu settings
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: extension
|
||||
name: i18nmenu
|
||||
constants:
|
||||
target_type: 'menu_link_content'
|
||||
langcode: 'site_default'
|
||||
process:
|
||||
target_entity_type_id: 'constants/target_type'
|
||||
# menu_link_content has a bundle key but no bundle support so use the entity
|
||||
# type as the bundle.
|
||||
target_bundle: 'constants/target_type'
|
||||
default_langcode: 'constants/langcode'
|
||||
# Drupal 6 menus are translated when the i18nmenu module is enabled.
|
||||
language_alterable: status
|
||||
destination:
|
||||
plugin: entity:language_content_settings
|
||||
@@ -20,6 +20,8 @@ process:
|
||||
0: NULL
|
||||
1: 'current_interface'
|
||||
2: 'current_interface'
|
||||
4: 'und'
|
||||
default_value: NULL
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
@@ -38,6 +40,7 @@ process:
|
||||
0: NULL
|
||||
1: false
|
||||
2: true
|
||||
4: true
|
||||
destination:
|
||||
plugin: entity:language_content_settings
|
||||
content_translation_update_definitions:
|
||||
|
||||
@@ -16,6 +16,13 @@ use Drupal\language\ConfigurableLanguageInterface;
|
||||
* @ConfigEntityType(
|
||||
* id = "configurable_language",
|
||||
* label = @Translation("Language"),
|
||||
* label_collection = @Translation("Languages"),
|
||||
* label_singular = @Translation("language"),
|
||||
* label_plural = @Translation("languages"),
|
||||
* label_count = @PluralTranslation(
|
||||
* singular = "@count language",
|
||||
* plural = "@count languages",
|
||||
* ),
|
||||
* handlers = {
|
||||
* "list_builder" = "Drupal\language\LanguageListBuilder",
|
||||
* "access" = "Drupal\language\LanguageAccessControlHandler",
|
||||
@@ -139,6 +146,14 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
|
||||
// Install any available language configuration overrides for the language.
|
||||
\Drupal::service('language.config_factory_override')->installLanguageOverrides($this->id());
|
||||
}
|
||||
|
||||
if (!$this->isLocked() && !$update) {
|
||||
// Add language to the list of language domains.
|
||||
$config = \Drupal::configFactory()->getEditable('language.negotiation');
|
||||
$domains = $config->get('url.domains');
|
||||
$domains[$this->id()] = '';
|
||||
$config->set('url.domains', $domains)->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,6 +188,12 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
|
||||
if (!\Drupal::languageManager()->isMultilingual()) {
|
||||
ConfigurableLanguageManager::rebuildServices();
|
||||
}
|
||||
|
||||
// Remove language from language prefix and domain list.
|
||||
$config = \Drupal::configFactory()->getEditable('language.negotiation');
|
||||
$config->clear('url.prefixes.' . $entity->id());
|
||||
$config->clear('url.domains.' . $entity->id());
|
||||
$config->save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,13 @@ use Drupal\language\ContentLanguageSettingsInterface;
|
||||
* @ConfigEntityType(
|
||||
* id = "language_content_settings",
|
||||
* label = @Translation("Content Language Settings"),
|
||||
* label_collection = @Translation("Content Language Settings"),
|
||||
* label_singular = @Translation("content language setting"),
|
||||
* label_plural = @Translation("content languages settings"),
|
||||
* label_count = @PluralTranslation(
|
||||
* singular = "@count content language setting",
|
||||
* plural = "@count content languages settings",
|
||||
* ),
|
||||
* admin_permission = "administer languages",
|
||||
* config_prefix = "content_settings",
|
||||
* entity_keys = {
|
||||
|
||||
@@ -34,7 +34,7 @@ class LanguageRequestSubscriber implements EventSubscriberInterface {
|
||||
/**
|
||||
* The translation service.
|
||||
*
|
||||
* @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface;
|
||||
* @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface
|
||||
*/
|
||||
protected $translation;
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ class ContentLanguageSettingsForm extends FormBase {
|
||||
->save();
|
||||
}
|
||||
}
|
||||
drupal_set_message($this->t('Settings successfully updated.'));
|
||||
$this->messenger()->addStatus($this->t('Settings successfully updated.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,12 +88,12 @@ class LanguageAddForm extends LanguageFormBase {
|
||||
|
||||
$t_args = ['%language' => $this->entity->label(), '%langcode' => $this->entity->id()];
|
||||
$this->logger('language')->notice('The %language (%langcode) language has been created.', $t_args);
|
||||
drupal_set_message($this->t('The language %language has been created and can now be used.', $t_args));
|
||||
$this->messenger()->addStatus($this->t('The language %language has been created and can now be used.', $t_args));
|
||||
|
||||
if ($this->moduleHandler->moduleExists('block')) {
|
||||
// Tell the user they have the option to add a language switcher block
|
||||
// to their theme so they can switch between the languages.
|
||||
drupal_set_message($this->t('Use one of the language switcher blocks to allow site visitors to switch between languages. You can enable these blocks on the <a href=":block-admin">block administration page</a>.', [':block-admin' => $this->url('block.admin_display')]));
|
||||
$this->messenger()->addStatus($this->t('Use one of the language switcher blocks to allow site visitors to switch between languages. You can enable these blocks on the <a href=":block-admin">block administration page</a>.', [':block-admin' => $this->url('block.admin_display')]));
|
||||
}
|
||||
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ abstract class LanguageFormBase extends EntityForm {
|
||||
$form['langcode_view'] = [
|
||||
'#type' => 'item',
|
||||
'#title' => $this->t('Language code'),
|
||||
'#markup' => $language->id()
|
||||
'#markup' => $language->id(),
|
||||
];
|
||||
$form['langcode'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $language->id()
|
||||
'#value' => $language->id(),
|
||||
];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -29,7 +29,6 @@ class NegotiationBrowserDeleteForm extends ConfirmFormBase {
|
||||
return ['language.mappings'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -76,7 +75,7 @@ class NegotiationBrowserDeleteForm extends ConfirmFormBase {
|
||||
|
||||
$this->logger('language')->notice('The browser language detection mapping for the %browser browser language code has been deleted.', $args);
|
||||
|
||||
drupal_set_message($this->t('The mapping for the %browser browser language code has been deleted.', $args));
|
||||
$this->messenger()->addStatus($this->t('The mapping for the %browser browser language code has been deleted.', $args));
|
||||
|
||||
$form_state->setRedirect('language.negotiation_browser');
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\language\Form;
|
||||
|
||||
use Drupal\Core\Block\BlockManagerInterface;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Extension\ThemeHandlerInterface;
|
||||
@@ -204,7 +203,7 @@ class NegotiationConfigureForm extends ConfigFormBase {
|
||||
$this->blockManager->clearCachedDefinitions();
|
||||
|
||||
$form_state->setRedirect('language.negotiation');
|
||||
drupal_set_message($this->t('Language detection configuration saved.'));
|
||||
$this->messenger()->addStatus($this->t('Language detection configuration saved.'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +235,7 @@ class NegotiationConfigureForm extends ConfigFormBase {
|
||||
'#attributes' => ['class' => ['language-customization-checkbox']],
|
||||
'#attached' => [
|
||||
'library' => [
|
||||
'language/drupal.language.admin'
|
||||
'language/drupal.language.admin',
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -276,7 +275,7 @@ class NegotiationConfigureForm extends ConfigFormBase {
|
||||
|
||||
$table_form['weight'][$method_id] = [
|
||||
'#type' => 'weight',
|
||||
'#title' => $this->t('Weight for @title language detection method', ['@title' => Unicode::strtolower($method_name)]),
|
||||
'#title' => $this->t('Weight for @title language detection method', ['@title' => mb_strtolower($method_name)]),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $weight,
|
||||
'#attributes' => ['class' => ["language-method-weight-$type"]],
|
||||
@@ -287,7 +286,7 @@ class NegotiationConfigureForm extends ConfigFormBase {
|
||||
|
||||
$table_form['enabled'][$method_id] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Enable @title language detection method', ['@title' => Unicode::strtolower($method_name)]),
|
||||
'#title' => $this->t('Enable @title language detection method', ['@title' => mb_strtolower($method_name)]),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $enabled,
|
||||
];
|
||||
|
||||
@@ -60,7 +60,6 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa
|
||||
*/
|
||||
protected $configSubscriber;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a PathProcessorLanguage object.
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Messenger\MessengerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
@@ -37,6 +38,13 @@ class LanguageListBuilder extends DraggableListBuilder {
|
||||
*/
|
||||
protected $configFactory;
|
||||
|
||||
/**
|
||||
* The messenger.
|
||||
*
|
||||
* @var \Drupal\Core\Messenger\MessengerInterface
|
||||
*/
|
||||
protected $messenger;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -45,7 +53,8 @@ class LanguageListBuilder extends DraggableListBuilder {
|
||||
$entity_type,
|
||||
$container->get('entity.manager')->getStorage($entity_type->id()),
|
||||
$container->get('language_manager'),
|
||||
$container->get('config.factory')
|
||||
$container->get('config.factory'),
|
||||
$container->get('messenger')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -60,11 +69,14 @@ class LanguageListBuilder extends DraggableListBuilder {
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The factory for configuration objects.
|
||||
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
|
||||
* The messenger.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory) {
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, MessengerInterface $messenger) {
|
||||
parent::__construct($entity_type, $storage);
|
||||
$this->languageManager = $language_manager;
|
||||
$this->configFactory = $config_factory;
|
||||
$this->messenger = $messenger;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +166,7 @@ class LanguageListBuilder extends DraggableListBuilder {
|
||||
$this->languageManager->updateLockedLanguageWeights();
|
||||
}
|
||||
|
||||
drupal_set_message(t('Configuration saved.'));
|
||||
$this->messenger->addStatus($this->t('Configuration saved.'));
|
||||
// Force the redirection to the page with the language we have just
|
||||
// selected as default.
|
||||
$form_state->setRedirectUrl($this->entities[$new_id]->urlInfo('collection', ['language' => $this->entities[$new_id]]));
|
||||
|
||||
@@ -57,7 +57,6 @@ class LanguageBlock extends BlockBase implements ContainerFactoryPluginInterface
|
||||
$this->pathMatcher = $path_matcher;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -71,7 +70,6 @@ class LanguageBlock extends BlockBase implements ContainerFactoryPluginInterface
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ class LanguageDomains extends ArrayBuild {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if ($row->getSourceProperty('domain_negotiation')) {
|
||||
if ($row->getSourceProperty('domain_negotiation_used')) {
|
||||
global $base_url;
|
||||
|
||||
foreach ($value as $old_key => $old_value) {
|
||||
|
||||
@@ -66,7 +66,7 @@ class Language extends DrupalSqlBase {
|
||||
// when the 'language_negotiation' variable is set to '3', and in D7, when
|
||||
// the 'locale_language_negotiation_url_part' variable is set to '1'.
|
||||
if ($this->variableGet('language_negotiation', 0) == 3 || $this->variableGet('locale_language_negotiation_url_part', 0) == 1) {
|
||||
$row->setSourceProperty('domain_negotiation', TRUE);
|
||||
$row->setSourceProperty('domain_negotiation_used', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@ core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
||||
dependencies:
|
||||
- entity_test
|
||||
- drupal:entity_test
|
||||
|
||||
@@ -15,7 +15,7 @@ use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI;
|
||||
function language_test_page_top() {
|
||||
if (\Drupal::moduleHandler()->moduleExists('language')) {
|
||||
language_test_store_language_negotiation();
|
||||
drupal_set_message(t('Language negotiation method: @name', ['@name' => \Drupal::languageManager()->getNegotiatedLanguageMethod()]));
|
||||
\Drupal::messenger()->addStatus(t('Language negotiation method: @name', ['@name' => \Drupal::languageManager()->getNegotiatedLanguageMethod()]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\language\Functional\Rest\ConfigurableLanguageResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ConfigurableLanguageHalJsonAnonTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\language\Functional\Rest\ConfigurableLanguageResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ConfigurableLanguageHalJsonBasicAuthTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal', 'basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\language\Functional\Rest\ConfigurableLanguageResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ConfigurableLanguageHalJsonCookieTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\language\Functional\Rest\ContentLanguageSettingsResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ContentLanguageSettingsHalJsonAnonTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\language\Functional\Rest\ContentLanguageSettingsResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ContentLanguageSettingsHalJsonBasicAuthTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal', 'basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\language\Functional\Rest\ContentLanguageSettingsResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ContentLanguageSettingsHalJsonCookieTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
@@ -170,7 +170,7 @@ class LanguageConfigurationElementTest extends BrowserTestBase {
|
||||
$this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Article content type.');
|
||||
// Update the article content type by changing the title label.
|
||||
$edit = [
|
||||
'title_label' => 'Name'
|
||||
'title_label' => 'Name',
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
|
||||
// Check that we still have the settings for the updated node type.
|
||||
@@ -189,7 +189,7 @@ class LanguageConfigurationElementTest extends BrowserTestBase {
|
||||
if ($this->profile != 'standard') {
|
||||
$this->drupalCreateContentType([
|
||||
'type' => 'article',
|
||||
'name' => 'Article'
|
||||
'name' => 'Article',
|
||||
]);
|
||||
}
|
||||
$admin_user = $this->drupalCreateUser(['administer content types']);
|
||||
@@ -240,7 +240,7 @@ class LanguageConfigurationElementTest extends BrowserTestBase {
|
||||
$this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Country vocabulary.');
|
||||
// Update the vocabulary.
|
||||
$edit = [
|
||||
'name' => 'Nation'
|
||||
'name' => 'Nation',
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save'));
|
||||
// Check that we still have the settings for the updated vocabulary.
|
||||
|
||||
@@ -90,7 +90,7 @@ class LanguageNegotiationContentEntityTest extends BrowserTestBase {
|
||||
$config->set('configurable', [LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT]);
|
||||
$config->set('negotiation.language_content.enabled', [
|
||||
LanguageNegotiationUrl::METHOD_ID => 0,
|
||||
LanguageNegotiationContentEntity::METHOD_ID => 1
|
||||
LanguageNegotiationContentEntity::METHOD_ID => 1,
|
||||
]);
|
||||
$config->save();
|
||||
|
||||
@@ -105,7 +105,7 @@ class LanguageNegotiationContentEntityTest extends BrowserTestBase {
|
||||
// language-url.
|
||||
$config->set('negotiation.language_content.enabled', [
|
||||
LanguageNegotiationContentEntity::METHOD_ID => 0,
|
||||
LanguageNegotiationUrl::METHOD_ID => 1
|
||||
LanguageNegotiationUrl::METHOD_ID => 1,
|
||||
]);
|
||||
$config->save();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class LanguageSelectorTranslatableTest extends BrowserTestBase {
|
||||
/**
|
||||
* The user with administrator privileges.
|
||||
*
|
||||
* @var \Drupal\user\Entity\User;
|
||||
* @var \Drupal\user\Entity\User
|
||||
*/
|
||||
public $administrator;
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class LanguageUrlRewritingTest extends BrowserTestBase {
|
||||
$edit = [
|
||||
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
|
||||
'domain[en]' => $base_url_host,
|
||||
'domain[fr]' => $language_domain
|
||||
'domain[fr]' => $language_domain,
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
|
||||
// Rebuild the container so that the new language gets picked up by services
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigurableLanguageJsonAnonTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigurableLanguageJsonBasicAuthTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigurableLanguageJsonCookieTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
|
||||
abstract class ConfigurableLanguageResourceTestBase extends EntityResourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['language'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $entityTypeId = 'configurable_language';
|
||||
|
||||
/**
|
||||
* @var \Drupal\language\ConfigurableLanguageInterface
|
||||
*/
|
||||
protected $entity;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpAuthorization($method) {
|
||||
$this->grantPermissionsToTestedRole(['administer languages']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createEntity() {
|
||||
$configurable_language = ConfigurableLanguage::create([
|
||||
'id' => 'll',
|
||||
'label' => 'Llama Language',
|
||||
]);
|
||||
$configurable_language->save();
|
||||
|
||||
return $configurable_language;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
return [
|
||||
'dependencies' => [],
|
||||
'direction' => 'ltr',
|
||||
'id' => 'll',
|
||||
'label' => 'Llama Language',
|
||||
'langcode' => 'en',
|
||||
'locked' => FALSE,
|
||||
'status' => TRUE,
|
||||
'uuid' => $this->entity->uuid(),
|
||||
'weight' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedCacheContexts() {
|
||||
return Cache::mergeContexts(parent::getExpectedCacheContexts(), ['languages:language_interface']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
// @todo Update in https://www.drupal.org/node/2300677.
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a GET request for a default config entity, which has a _core key.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2915414
|
||||
*/
|
||||
public function testGetDefaultConfig() {
|
||||
$this->initAuthentication();
|
||||
$url = Url::fromUri('base:/entity/configurable_language/en')->setOption('query', ['_format' => static::$format]);;
|
||||
$request_options = $this->getAuthenticationRequestOptions('GET');
|
||||
$this->provisionEntityResource();
|
||||
$this->setUpAuthorization('GET');
|
||||
$response = $this->request('GET', $url, $request_options);
|
||||
|
||||
$normalization = $this->serializer->decode((string) $response->getBody(), static::$format);
|
||||
$this->assertArrayNotHasKey('_core', $normalization);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigurableLanguageXmlAnonTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigurableLanguageXmlBasicAuthTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigurableLanguageXmlCookieTest extends ConfigurableLanguageResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ContentLanguageSettingsJsonAnonTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ContentLanguageSettingsJsonBasicAuthTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ContentLanguageSettingsJsonCookieTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\language\Entity\ContentLanguageSettings;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
|
||||
|
||||
abstract class ContentLanguageSettingsResourceTestBase extends EntityResourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['language', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $entityTypeId = 'language_content_settings';
|
||||
|
||||
/**
|
||||
* @var \Drupal\language\ContentLanguageSettingsInterface
|
||||
*/
|
||||
protected $entity;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpAuthorization($method) {
|
||||
$this->grantPermissionsToTestedRole(['administer languages']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createEntity() {
|
||||
// Create a "Camelids" node type.
|
||||
$camelids = NodeType::create([
|
||||
'name' => 'Camelids',
|
||||
'type' => 'camelids',
|
||||
]);
|
||||
$camelids->save();
|
||||
|
||||
$entity = ContentLanguageSettings::create([
|
||||
'target_entity_type_id' => 'node',
|
||||
'target_bundle' => 'camelids',
|
||||
]);
|
||||
$entity->setDefaultLangcode('site_default')
|
||||
->save();
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
return [
|
||||
'default_langcode' => 'site_default',
|
||||
'dependencies' => [
|
||||
'config' => [
|
||||
'node.type.camelids',
|
||||
],
|
||||
],
|
||||
'id' => 'node.camelids',
|
||||
'langcode' => 'en',
|
||||
'language_alterable' => FALSE,
|
||||
'status' => TRUE,
|
||||
'target_bundle' => 'camelids',
|
||||
'target_entity_type_id' => 'node',
|
||||
'uuid' => $this->entity->uuid(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
// @todo Update in https://www.drupal.org/node/2300677.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedCacheContexts() {
|
||||
return [
|
||||
'languages:language_interface',
|
||||
'user.permissions',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ContentLanguageSettingsXmlAnonTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ContentLanguageSettingsXmlBasicAuthTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use BasicAuthResourceWithInterfaceTranslationTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ContentLanguageSettingsXmlCookieTest extends ContentLanguageSettingsResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
* Tests the update path for the language_select widget.
|
||||
*
|
||||
* @group Update
|
||||
* @group legacy
|
||||
*/
|
||||
class LanguageSelectWidgetUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class EntityUrlLanguageTest extends LanguageTestBase {
|
||||
$config->set('configurable', [LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT]);
|
||||
$config->set('negotiation.language_content.enabled', [
|
||||
LanguageNegotiationContentEntity::METHOD_ID => 0,
|
||||
LanguageNegotiationUrl::METHOD_ID => 1
|
||||
LanguageNegotiationUrl::METHOD_ID => 1,
|
||||
]);
|
||||
$config->save();
|
||||
|
||||
@@ -98,7 +98,7 @@ class EntityUrlLanguageTest extends LanguageTestBase {
|
||||
// where the language-content-entity is turned off.
|
||||
$config->set('negotiation.language_content.enabled', [
|
||||
LanguageNegotiationUrl::METHOD_ID => 0,
|
||||
LanguageNegotiationContentEntity::METHOD_ID => 1
|
||||
LanguageNegotiationContentEntity::METHOD_ID => 1,
|
||||
]);
|
||||
$config->save();
|
||||
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\language\Entity\ContentLanguageSettings;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of the ability to translate menu content.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateLanguageContentMenuSettingsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'language',
|
||||
'content_translation',
|
||||
'menu_link_content',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Create some languages.
|
||||
ConfigurableLanguage::createFromLangcode('en')->save();
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
$this->executeMigrations(['d6_language_content_menu_settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of menu translation ability.
|
||||
*/
|
||||
public function testLanguageMenuContent() {
|
||||
$config = ContentLanguageSettings::load('menu_link_content.menu_link_content');
|
||||
$this->assertInstanceOf(ContentLanguageSettings::class, $config);
|
||||
$this->assertSame('menu_link_content', $config->getTargetEntityTypeId());
|
||||
$this->assertSame('menu_link_content', $config->getTargetBundle());
|
||||
$this->assertSame(LanguageInterface::LANGCODE_SITE_DEFAULT, $config->getDefaultLangcode());
|
||||
$this->assertTrue($config->isLanguageAlterable());
|
||||
|
||||
// Test that menus are not alterable when the i18nmenu is not enabled.
|
||||
$this->sourceDatabase->update('system')
|
||||
->fields(['status' => 0])
|
||||
->condition('name', 'i18nmenu')
|
||||
->execute();
|
||||
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = $this->getMigration('d6_language_content_menu_settings');
|
||||
// Indicate we're rerunning a migration that's already run.
|
||||
$migration->getIdMap()->prepareUpdate();
|
||||
$this->executeMigration($migration);
|
||||
|
||||
$config = ContentLanguageSettings::load('menu_link_content.menu_link_content');
|
||||
$this->assertInstanceOf(ContentLanguageSettings::class, $config);
|
||||
$this->assertSame('menu_link_content', $config->getTargetEntityTypeId());
|
||||
$this->assertSame('menu_link_content', $config->getTargetBundle());
|
||||
$this->assertSame(LanguageInterface::LANGCODE_SITE_DEFAULT, $config->getDefaultLangcode());
|
||||
$this->assertFalse($config->isLanguageAlterable());
|
||||
}
|
||||
|
||||
}
|
||||
+21
-3
@@ -17,6 +17,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'text', 'language', 'content_translation', 'menu_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -33,9 +34,9 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
|
||||
public function testLanguageContent() {
|
||||
// Assert that a translatable content is still translatable.
|
||||
$config = $this->config('language.content_settings.node.blog');
|
||||
$this->assertIdentical($config->get('target_entity_type_id'), 'node');
|
||||
$this->assertIdentical($config->get('target_bundle'), 'blog');
|
||||
$this->assertIdentical($config->get('default_langcode'), 'current_interface');
|
||||
$this->assertSame($config->get('target_entity_type_id'), 'node');
|
||||
$this->assertSame($config->get('target_bundle'), 'blog');
|
||||
$this->assertSame($config->get('default_langcode'), 'current_interface');
|
||||
$this->assertFalse($config->get('language_alterable'));
|
||||
$this->assertTrue($config->get('third_party_settings.content_translation.enabled'));
|
||||
|
||||
@@ -45,6 +46,23 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
|
||||
$this->assertFalse($config->isLanguageAlterable());
|
||||
$this->assertSame($config->getDefaultLangcode(), 'site_default');
|
||||
|
||||
// Make sure there's no migration exceptions.
|
||||
$messages = $this->migration->getIdMap()->getMessageIterator()->fetchAll();
|
||||
$this->assertEmpty($messages);
|
||||
|
||||
// Assert that a content type translatable with entity_translation is still
|
||||
// translatable.
|
||||
$config = $this->config('language.content_settings.node.test_content_type');
|
||||
$this->assertTrue($config->get('third_party_settings.content_translation.enabled'));
|
||||
$this->assertSame($config->get('default_langcode'), 'und');
|
||||
|
||||
// Assert that a content type without a 'language_content_type' variable is
|
||||
// not translatable
|
||||
$config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'book');
|
||||
$this->assertTrue($config->isDefaultConfiguration());
|
||||
$this->assertFalse($config->isLanguageAlterable());
|
||||
$this->assertSame($config->getDefaultLangcode(), 'site_default');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
@@ -53,6 +53,10 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal7TestBase {
|
||||
* Tests the migration with prefix negotiation.
|
||||
*/
|
||||
public function testLanguageNegotiationWithPrefix() {
|
||||
$this->sourceDatabase->update('languages')
|
||||
->fields(['domain' => ''])
|
||||
->execute();
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd7_language_negotiation_settings',
|
||||
@@ -65,9 +69,20 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal7TestBase {
|
||||
$this->assertSame('site_default', $config->get('selected_langcode'));
|
||||
$expected_prefixes = [
|
||||
'en' => '',
|
||||
'fr' => 'fr',
|
||||
'is' => 'is',
|
||||
];
|
||||
$this->assertSame($expected_prefixes, $config->get('url.prefixes'));
|
||||
|
||||
// If prefix negotiation is used, make sure that no domains are migrated.
|
||||
// Otherwise there will be validation errors when trying to save URL
|
||||
// language detection configuration from the UI.
|
||||
$expected_domains = [
|
||||
'en' => '',
|
||||
'fr' => '',
|
||||
'is' => '',
|
||||
];
|
||||
$this->assertSame($expected_domains, $config->get('url.domains'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,6 +107,7 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal7TestBase {
|
||||
$this->assertSame('site_default', $config->get('selected_langcode'));
|
||||
$expected_domains = [
|
||||
'en' => parse_url($base_url, PHP_URL_HOST),
|
||||
'fr' => 'fr.drupal.org',
|
||||
'is' => 'is.drupal.org',
|
||||
];
|
||||
$this->assertSame($expected_domains, $config->get('url.domains'));
|
||||
@@ -117,6 +133,7 @@ class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal7TestBase {
|
||||
$this->assertSame('site_default', $config->get('selected_langcode'));
|
||||
$expected_prefixes = [
|
||||
'en' => '',
|
||||
'fr' => 'fr',
|
||||
'is' => 'is',
|
||||
];
|
||||
$this->assertSame($expected_prefixes, $config->get('url.prefixes'));
|
||||
|
||||
@@ -48,7 +48,7 @@ class FilterLanguageTest extends LanguageTestBase {
|
||||
'en',
|
||||
'xx-lolspeak',
|
||||
'und',
|
||||
'zxx'
|
||||
'zxx',
|
||||
];
|
||||
$this->assertIdentical(array_keys($view->filter['langcode']->getValueOptions()), $expected);
|
||||
|
||||
|
||||
@@ -256,7 +256,9 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
|
||||
namespace Drupal\language\Plugin\LanguageNegotiation;
|
||||
|
||||
if (!function_exists('base_path')) {
|
||||
|
||||
function base_path() {
|
||||
return '/';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user