Update to Drupal 8.2.4. For more information, see https://www.drupal.org/project/drupal/releases/8.2.4
This commit is contained in:
parent
0a95b8440e
commit
8544b60b39
284 changed files with 12980 additions and 3199 deletions
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Tests the migration of language negotiation and language types.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['language'];
|
||||
|
||||
/**
|
||||
* Tests the migration with LANGUAGE_NEGOTIATION_PATH_DEFAULT.
|
||||
*/
|
||||
public function testLanguageNegotiationWithDefaultPathPrefix() {
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_language_negotiation_settings',
|
||||
'language_prefixes_and_domains',
|
||||
'd6_language_types',
|
||||
]);
|
||||
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertSame($config->get('session.parameter'), 'language');
|
||||
$this->assertSame($config->get('url.source'), LanguageNegotiationUrl::CONFIG_PATH_PREFIX);
|
||||
$this->assertSame($config->get('selected_langcode'), 'site_default');
|
||||
$expected_prefixes = [
|
||||
'en' => '',
|
||||
'fr' => 'fr',
|
||||
'zu' => 'zu',
|
||||
];
|
||||
$this->assertSame($config->get('url.prefixes'), $expected_prefixes);
|
||||
|
||||
$config = $this->config('language.types');
|
||||
$this->assertSame($config->get('all'), ['language_interface', 'language_content', 'language_url']);
|
||||
$this->assertSame($config->get('configurable'), ['language_interface']);
|
||||
$this->assertSame($config->get('negotiation.language_content.enabled'), ['language-interface' => 0]);
|
||||
$this->assertSame($config->get('negotiation.language_url.enabled'), ['language-url' => 0, 'language-url-fallback' => 1]);
|
||||
$expected_language_interface = [
|
||||
'language-url' => 0,
|
||||
'language-selected' => 1,
|
||||
];
|
||||
$this->assertSame($config->get('negotiation.language_interface.enabled'), $expected_language_interface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration with LANGUAGE_NEGOTIATION_NONE.
|
||||
*/
|
||||
public function testLanguageNegotiationWithNoNegotiation() {
|
||||
$this->sourceDatabase->update('variable')
|
||||
->fields(array('value' => serialize(0)))
|
||||
->condition('name', 'language_negotiation')
|
||||
->execute();
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_language_negotiation_settings',
|
||||
'language_prefixes_and_domains',
|
||||
'd6_language_types',
|
||||
]);
|
||||
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertSame($config->get('session.parameter'), 'language');
|
||||
$this->assertSame($config->get('url.source'), LanguageNegotiationUrl::CONFIG_PATH_PREFIX);
|
||||
$this->assertSame($config->get('selected_langcode'), 'site_default');
|
||||
|
||||
$config = $this->config('language.types');
|
||||
$this->assertSame($config->get('all'), ['language_interface', 'language_content', 'language_url']);
|
||||
$this->assertSame($config->get('configurable'), ['language_interface']);
|
||||
$this->assertSame($config->get('negotiation.language_content.enabled'), ['language-interface' => 0]);
|
||||
$this->assertSame($config->get('negotiation.language_url.enabled'), ['language-url' => 0, 'language-url-fallback' => 1]);
|
||||
$expected_language_interface = [
|
||||
'language-selected' => 0,
|
||||
];
|
||||
$this->assertSame($config->get('negotiation.language_interface.enabled'), $expected_language_interface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration with LANGUAGE_NEGOTIATION_PATH.
|
||||
*/
|
||||
public function testLanguageNegotiationWithPathPrefix() {
|
||||
$this->sourceDatabase->update('variable')
|
||||
->fields(array('value' => serialize(2)))
|
||||
->condition('name', 'language_negotiation')
|
||||
->execute();
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_language_negotiation_settings',
|
||||
'language_prefixes_and_domains',
|
||||
'd6_language_types',
|
||||
]);
|
||||
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertSame($config->get('session.parameter'), 'language');
|
||||
$this->assertSame($config->get('url.source'), LanguageNegotiationUrl::CONFIG_PATH_PREFIX);
|
||||
$this->assertSame($config->get('selected_langcode'), 'site_default');
|
||||
$expected_prefixes = [
|
||||
'en' => '',
|
||||
'fr' => 'fr',
|
||||
'zu' => 'zu',
|
||||
];
|
||||
$this->assertSame($config->get('url.prefixes'), $expected_prefixes);
|
||||
|
||||
$config = $this->config('language.types');
|
||||
$this->assertSame($config->get('all'), ['language_interface', 'language_content', 'language_url']);
|
||||
$this->assertSame($config->get('configurable'), ['language_interface']);
|
||||
$this->assertSame($config->get('negotiation.language_content.enabled'), ['language-interface' => 0]);
|
||||
$this->assertSame($config->get('negotiation.language_url.enabled'), ['language-url' => 0, 'language-url-fallback' => 1]);
|
||||
$expected_language_interface = [
|
||||
'language-url' => 0,
|
||||
'language-user' => 1,
|
||||
'language-browser' => 2,
|
||||
'language-selected' => 3,
|
||||
];
|
||||
$this->assertSame($config->get('negotiation.language_interface.enabled'), $expected_language_interface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration with LANGUAGE_NEGOTIATION_DOMAIN.
|
||||
*/
|
||||
public function testLanguageNegotiationWithDomain() {
|
||||
$this->sourceDatabase->update('variable')
|
||||
->fields(array('value' => serialize(3)))
|
||||
->condition('name', 'language_negotiation')
|
||||
->execute();
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_language_negotiation_settings',
|
||||
'language_prefixes_and_domains',
|
||||
'd6_language_types',
|
||||
]);
|
||||
|
||||
global $base_url;
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertSame($config->get('session.parameter'), 'language');
|
||||
$this->assertSame($config->get('url.source'), LanguageNegotiationUrl::CONFIG_DOMAIN);
|
||||
$this->assertSame($config->get('selected_langcode'), 'site_default');
|
||||
$expected_domains = [
|
||||
'en' => parse_url($base_url, PHP_URL_HOST),
|
||||
'fr' => 'fr.drupal.org',
|
||||
'zu' => 'zu.drupal.org',
|
||||
];
|
||||
$this->assertSame($config->get('url.domains'), $expected_domains);
|
||||
|
||||
$config = $this->config('language.types');
|
||||
$this->assertSame($config->get('all'), ['language_interface', 'language_content', 'language_url']);
|
||||
$this->assertSame($config->get('configurable'), ['language_interface']);
|
||||
$this->assertSame($config->get('negotiation.language_content.enabled'), ['language-interface' => 0]);
|
||||
$this->assertSame($config->get('negotiation.language_url.enabled'), ['language-url' => 0, 'language-url-fallback' => 1]);
|
||||
$expected_language_interface = [
|
||||
'language-url' => 0,
|
||||
'language-selected' => 1,
|
||||
];
|
||||
$this->assertSame($config->get('negotiation.language_interface.enabled'), $expected_language_interface);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,37 +2,124 @@
|
|||
|
||||
namespace Drupal\Tests\language\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of language negotiation variables.
|
||||
* Tests the migration of language negotiation.
|
||||
*
|
||||
* @group language
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['language'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Tests migration of language types variables to language.types.yml.
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_language_negotiation_settings');
|
||||
public function testLanguageTypes() {
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd7_language_negotiation_settings',
|
||||
'd7_language_types',
|
||||
]);
|
||||
|
||||
$config = $this->config('language.types');
|
||||
$this->assertSame($config->get('all'), ['language_content', 'language_url', 'language_interface']);
|
||||
$this->assertSame($config->get('configurable'), ['language_interface']);
|
||||
$this->assertSame($config->get('negotiation.language_content'), ['enabled' => ['language-interface' => 0]]);
|
||||
$this->assertSame($config->get('negotiation.language_url'), ['enabled' => ['language-url' => 0, 'language-url-fallback' => 1]]);
|
||||
$expected_language_interface = [
|
||||
'enabled' => [
|
||||
'language-url' => -9,
|
||||
'language-user' => -10,
|
||||
'language-selected' => -6,
|
||||
],
|
||||
'method_weights' => [
|
||||
'language-url' => -9,
|
||||
'language-session' => -8,
|
||||
'language-user' => -10,
|
||||
'language-browser' => -7,
|
||||
'language-selected' => -6,
|
||||
],
|
||||
];
|
||||
$this->assertSame($config->get('negotiation.language_interface'), $expected_language_interface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of language negotiation variables to language.negotiation.yml.
|
||||
* Tests the migration with prefix negotiation.
|
||||
*/
|
||||
public function testLanguageNegotiation() {
|
||||
public function testLanguageNegotiationWithPrefix() {
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd7_language_negotiation_settings',
|
||||
'language_prefixes_and_domains',
|
||||
]);
|
||||
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertIdentical($config->get('session.parameter'), 'language');
|
||||
$this->assertIdentical($config->get('url.source'), 'domain');
|
||||
$this->assertSame($config->get('session.parameter'), 'language');
|
||||
$this->assertSame($config->get('url.source'), LanguageNegotiationUrl::CONFIG_PATH_PREFIX);
|
||||
$this->assertSame($config->get('selected_langcode'), 'site_default');
|
||||
$expected_prefixes = [
|
||||
'en' => '',
|
||||
'is' => 'is',
|
||||
];
|
||||
$this->assertSame($config->get('url.prefixes'), $expected_prefixes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration with domain negotiation.
|
||||
*/
|
||||
public function testLanguageNegotiationWithDomain() {
|
||||
$this->sourceDatabase->update('variable')
|
||||
->fields(array('value' => serialize(1)))
|
||||
->condition('name', 'locale_language_negotiation_url_part')
|
||||
->execute();
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd7_language_negotiation_settings',
|
||||
'language_prefixes_and_domains',
|
||||
]);
|
||||
|
||||
global $base_url;
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertSame($config->get('session.parameter'), 'language');
|
||||
$this->assertSame($config->get('url.source'), LanguageNegotiationUrl::CONFIG_DOMAIN);
|
||||
$this->assertSame($config->get('selected_langcode'), 'site_default');
|
||||
$expected_domains = [
|
||||
'en' => parse_url($base_url, PHP_URL_HOST),
|
||||
'is' => 'is.drupal.org',
|
||||
];
|
||||
$this->assertSame($config->get('url.domains'), $expected_domains);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration with non-existent variables.
|
||||
*/
|
||||
public function testLanguageNegotiationWithNonExistentVariables() {
|
||||
$this->sourceDatabase->delete('variable')
|
||||
->condition('name', ['local_language_negotiation_url_part', 'local_language_negotiation_session_param'], 'IN')
|
||||
->execute();
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_language_negotiation_settings',
|
||||
'language_prefixes_and_domains',
|
||||
]);
|
||||
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertSame($config->get('session.parameter'), 'language');
|
||||
$this->assertSame($config->get('url.source'), LanguageNegotiationUrl::CONFIG_PATH_PREFIX);
|
||||
$this->assertSame($config->get('selected_langcode'), 'site_default');
|
||||
$expected_prefixes = [
|
||||
'en' => '',
|
||||
'is' => 'is',
|
||||
];
|
||||
$this->assertSame($config->get('url.prefixes'), $expected_prefixes);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Unit\process;
|
||||
|
||||
use Drupal\language\Plugin\migrate\process\LanguageDomains;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\language\Plugin\migrate\process\LanguageDomains
|
||||
* @group language
|
||||
*/
|
||||
class LanguageDomainsTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $backupGlobalsBlacklist = ['base_url'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$configuration = [
|
||||
'key' => 'language',
|
||||
'value' => 'domain',
|
||||
];
|
||||
$this->plugin = new LanguageDomains($configuration, 'map', []);
|
||||
parent::setUp();
|
||||
|
||||
// The language_domains plugin calls getSourceProperty() to check if domain
|
||||
// negotiation is used. If it is the values will be processed so we need it
|
||||
// to return TRUE to be able to test the process.
|
||||
$this->row->expects($this->once())
|
||||
->method('getSourceProperty')
|
||||
->will($this->returnValue(TRUE));
|
||||
|
||||
// The language_domains plugin use $base_url to fill empty domains.
|
||||
global $base_url;
|
||||
$base_url = 'http://example.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::transform
|
||||
*/
|
||||
public function testTransform() {
|
||||
$source = [
|
||||
['language' => 'en', 'domain' => ''],
|
||||
['language' => 'fr', 'domain' => 'fr.example.com'],
|
||||
['language' => 'es', 'domain' => 'http://es.example.com'],
|
||||
['language' => 'hu', 'domain' => 'https://hu.example.com'],
|
||||
];
|
||||
$expected = [
|
||||
'en' => 'example.com',
|
||||
'fr' => 'fr.example.com',
|
||||
'es' => 'es.example.com',
|
||||
'hu' => 'hu.example.com',
|
||||
];
|
||||
$value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame($value, $expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Unit\process;
|
||||
|
||||
use Drupal\language\Plugin\migrate\process\LanguageNegotiation;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\language\Plugin\migrate\process\LanguageNegotiation
|
||||
* @group language
|
||||
*/
|
||||
class LanguageNegotiationTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->plugin = new LanguageNegotiation([], 'map', []);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests successful transformation without weights.
|
||||
*/
|
||||
public function testTransformWithWeights() {
|
||||
$source = [
|
||||
[
|
||||
'locale-url' => [],
|
||||
'language-default' => [],
|
||||
],
|
||||
[
|
||||
'locale-url' => -10,
|
||||
'locale-session' => -9,
|
||||
'locale-user' => -8,
|
||||
'locale-browser' => -7,
|
||||
'language-default' => -6,
|
||||
],
|
||||
];
|
||||
$expected = [
|
||||
'enabled' => [
|
||||
'language-url' => -10,
|
||||
'language-selected' => -6,
|
||||
],
|
||||
'method_weights' => [
|
||||
'language-url' => -10,
|
||||
'language-session' => -9,
|
||||
'language-user' => -8,
|
||||
'language-browser' => -7,
|
||||
'language-selected' => -6,
|
||||
],
|
||||
];
|
||||
$value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame($value, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests successful transformation without weights.
|
||||
*/
|
||||
public function testTransformWithoutWeights() {
|
||||
$source = [
|
||||
[
|
||||
'locale-url' => [],
|
||||
'locale-url-fallback' => [],
|
||||
],
|
||||
];
|
||||
$expected = [
|
||||
'enabled' => [
|
||||
'language-url' => 0,
|
||||
'language-url-fallback' => 1,
|
||||
],
|
||||
];
|
||||
$value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame($value, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests string input.
|
||||
*
|
||||
* @expectedException \Drupal\migrate\MigrateException
|
||||
* @expectedExceptionMessage The input should be an array
|
||||
*/
|
||||
public function testStringInput() {
|
||||
$this->plugin = new LanguageNegotiation([], 'map', []);
|
||||
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\language\Unit\process;
|
||||
|
||||
use Drupal\language\Plugin\migrate\process\LanguageTypes;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\language\Plugin\migrate\process\LanguageTypes
|
||||
* @group language
|
||||
*/
|
||||
class LanguageTypesTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* Tests successful transformation of all language types.
|
||||
*/
|
||||
public function testTransformAll() {
|
||||
$this->plugin = new LanguageTypes([], 'map', []);
|
||||
$source = [
|
||||
'language' => TRUE,
|
||||
'language_url' => FALSE,
|
||||
'language_content' => FALSE,
|
||||
];
|
||||
$expected = [
|
||||
0 => 'language_url',
|
||||
1 => 'language_content',
|
||||
2 => 'language_interface',
|
||||
];
|
||||
$value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame($value, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests successful transformation of configurable language types.
|
||||
*/
|
||||
public function testTransformConfigurable() {
|
||||
$this->plugin = new LanguageTypes(['filter_configurable' => TRUE], 'map', []);
|
||||
$source = [
|
||||
'language' => TRUE,
|
||||
'language_url' => FALSE,
|
||||
'language_content' => FALSE,
|
||||
];
|
||||
$expected = [
|
||||
0 => 'language_interface',
|
||||
];
|
||||
$value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame($value, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests string input.
|
||||
*
|
||||
* @expectedException \Drupal\migrate\MigrateException
|
||||
* @expectedExceptionMessage The input should be an array
|
||||
*/
|
||||
public function testStringInput() {
|
||||
$this->plugin = new LanguageTypes([], 'map', []);
|
||||
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue