Core and composer updates

This commit is contained in:
Rob Davies 2017-07-03 16:47:07 +01:00
parent a82634bb98
commit 62cac30480
1118 changed files with 21770 additions and 6306 deletions

View file

@ -1,76 +0,0 @@
<?php
namespace Drupal\Tests\language\Kernel\Migrate;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\migrate\Plugin\MigrationInterface;
/**
* Tests the default language variable migration.
*/
trait MigrateDefaultLanguageTrait {
/**
* Helper method to test the migration.
*
* @param string $langcode
* The langcode of the default language.
* @param bool $existing
* Whether the default language exists on the destination.
*/
protected function doTestMigration($langcode, $existing = TRUE) {
// The default language of the test fixture is English. Change it to
// something else before migrating, to be sure that the source site
// default language is migrated.
$value = 'O:8:"stdClass":11:{s:8:"language";s:2:"' . $langcode . '";s:4:"name";s:6:"French";s:6:"native";s:6:"French";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"0";s:7:"formula";s:0:"";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:1:"0";s:10:"javascript";s:0:"";}';
$this->sourceDatabase->update('variable')
->fields([
'value' => $value
])
->condition('name', 'language_default' )
->execute();
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
if ($existing) {
// If the default language exists, we should be able to load it and the
// default_langcode config should be set.
$default_language = ConfigurableLanguage::load($langcode);
$this->assertNotNull($default_language);
$this->assertSame($langcode, $this->config('system.site')->get('default_langcode'));
}
else {
// Otherwise, the migration log should contain an error message.
$messages = $this->migration->getIdMap()->getMessageIterator();
$count = 0;
foreach ($messages as $message) {
$count++;
$this->assertSame($message->message, "The language '$langcode' does not exist on this site.");
$this->assertSame((int) $message->level, MigrationInterface::MESSAGE_ERROR);
}
$this->assertSame($count, 1);
}
}
/**
* Helper method to test migrating the default language when no default language is set.
*/
protected function doTestMigrationWithUnsetVariable() {
// Delete the language_default variable.
$this->sourceDatabase->delete('variable')
->condition('name', 'language_default' )
->execute();
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
$messages = $this->migration->getIdMap()->getMessageIterator()->fetchAll();
// Make sure there's no migration exceptions.
$this->assertEmpty($messages);
// Make sure the default langcode is 'en', since it was the default on D6 & D7.
$this->assertSame('en', $this->config('system.site')->get('default_langcode'));
}
}

View file

@ -2,7 +2,8 @@
namespace Drupal\Tests\language\Kernel\Migrate\d6;
use Drupal\Tests\language\Kernel\Migrate\MigrateDefaultLanguageTrait;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
@ -12,8 +13,6 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
*/
class MigrateDefaultLanguageTest extends MigrateDrupal6TestBase {
use MigrateDefaultLanguageTrait;
/**
* {@inheritdoc}
*/
@ -23,21 +22,68 @@ class MigrateDefaultLanguageTest extends MigrateDrupal6TestBase {
* Tests language_default migration with an existing language.
*/
public function testMigrationWithExistingLanguage() {
$this->doTestMigration('fr');
$this->setDefaultLanguage('fr');
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
// Tests the language is loaded and is the default language.
$default_language = ConfigurableLanguage::load('fr');
$this->assertNotNull($default_language);
$this->assertSame('fr', $this->config('system.site')->get('default_langcode'));
}
/**
* Tests language_default migration with a non-existing language.
*/
public function testMigrationWithNonExistentLanguage() {
$this->doTestMigration('tv', FALSE);
$this->setDefaultLanguage('tv');
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
// Tests the migration log contains an error message.
$messages = $this->migration->getIdMap()->getMessageIterator();
$count = 0;
foreach ($messages as $message) {
$count++;
$this->assertSame($message->message, "The language 'tv' does not exist on this site.");
$this->assertSame((int) $message->level, MigrationInterface::MESSAGE_ERROR);
}
$this->assertSame($count, 1);
}
/**
* Tests language_default migration with unset variable.
* Tests language_default migration with unset default language variable.
*/
public function testMigrationWithUnsetVariable() {
$this->doTestMigrationWithUnsetVariable();
// Delete the language_default variable.
$this->sourceDatabase->delete('variable')
->condition('name', 'language_default')
->execute();
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
$messages = $this->migration->getIdMap()->getMessageIterator()->fetchAll();
// Make sure there's no migration exceptions.
$this->assertEmpty($messages);
// Make sure the default langcode is 'en', as it was the default on D6 & D7.
$this->assertSame('en', $this->config('system.site')->get('default_langcode'));
}
/**
* Helper method to test the migration.
*
* @param string $langcode
* The langcode of the default language.
*/
protected function setDefaultLanguage($langcode) {
// The default language of the test fixture is English. Change it to
// something else before migrating, to be sure that the source site
// default language is migrated.
$value = 'O:8:"stdClass":11:{s:8:"language";s:2:"' . $langcode . '";s:4:"name";s:6:"French";s:6:"native";s:6:"French";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"0";s:7:"formula";s:0:"";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:1:"0";s:10:"javascript";s:0:"";}';
$this->sourceDatabase->update('variable')
->fields(['value' => $value])
->condition('name', 'language_default')
->execute();
}
}

View file

@ -16,7 +16,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'text', 'language', 'content_translation'];
public static $modules = ['node', 'text', 'language', 'content_translation', 'menu_ui'];
/**
* {@inheritdoc}

View file

@ -2,7 +2,8 @@
namespace Drupal\Tests\language\Kernel\Migrate\d7;
use Drupal\Tests\language\Kernel\Migrate\MigrateDefaultLanguageTrait;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
@ -12,8 +13,6 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateDefaultLanguageTest extends MigrateDrupal7TestBase {
use MigrateDefaultLanguageTrait;
/**
* {@inheritdoc}
*/
@ -23,21 +22,68 @@ class MigrateDefaultLanguageTest extends MigrateDrupal7TestBase {
* Tests language_default migration with a non-existing language.
*/
public function testMigrationWithExistingLanguage() {
$this->doTestMigration('is');
$this->setDefaultLanguage('is');
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
// Tests the language is loaded and is the default language.
$default_language = ConfigurableLanguage::load('is');
$this->assertNotNull($default_language);
$this->assertSame('is', $this->config('system.site')->get('default_langcode'));
}
/**
* Tests language_default migration with a non-existing language.
*/
public function testMigrationWithNonExistentLanguage() {
$this->doTestMigration('tv', FALSE);
$this->setDefaultLanguage('tv');
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
// Tests the migration log contains an error message.
$messages = $this->migration->getIdMap()->getMessageIterator();
$count = 0;
foreach ($messages as $message) {
$count++;
$this->assertSame($message->message, "The language 'tv' does not exist on this site.");
$this->assertSame((int) $message->level, MigrationInterface::MESSAGE_ERROR);
}
$this->assertSame($count, 1);
}
/**
* Tests language_default migration with unset variable.
* Tests language_default migration with unset default language variable.
*/
public function testMigrationWithUnsetVariable() {
$this->doTestMigrationWithUnsetVariable();
// Delete the language_default variable.
$this->sourceDatabase->delete('variable')
->condition('name', 'language_default')
->execute();
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
$messages = $this->migration->getIdMap()->getMessageIterator()->fetchAll();
// Make sure there's no migration exceptions.
$this->assertEmpty($messages);
// Make sure the default langcode is 'en', as it was the default on D6 & D7.
$this->assertSame('en', $this->config('system.site')->get('default_langcode'));
}
/**
* Helper method to test the migration.
*
* @param string $langcode
* The langcode of the default language.
*/
protected function setDefaultLanguage($langcode) {
// The default language of the test fixture is English. Change it to
// something else before migrating, to be sure that the source site
// default language is migrated.
$value = 'O:8:"stdClass":11:{s:8:"language";s:2:"' . $langcode . '";s:4:"name";s:6:"French";s:6:"native";s:6:"French";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"0";s:7:"formula";s:0:"";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:1:"0";s:10:"javascript";s:0:"";}';
$this->sourceDatabase->update('variable')
->fields(['value' => $value])
->condition('name', 'language_default')
->execute();
}
}

View file

@ -16,7 +16,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'text', 'language', 'content_translation'];
public static $modules = ['node', 'text', 'language', 'content_translation', 'menu_ui'];
/**
* {@inheritdoc}
*/