Update to Drupal 8.0.6. For more information, see https://www.drupal.org/drupal-8.0.6-release-notes

This commit is contained in:
Pantheon Automation 2016-04-07 11:19:57 -07:00 committed by Greg Anderson
parent 4297c64508
commit b11a755ba8
159 changed files with 2340 additions and 543 deletions

View file

@ -10,6 +10,7 @@ namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\DependencyTrait;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row;
@ -38,6 +39,13 @@ class Config extends DestinationBase implements ContainerFactoryPluginInterface,
*/
protected $config;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $language_manager;
/**
* Constructs a Config destination object.
*
@ -51,10 +59,13 @@ class Config extends DestinationBase implements ContainerFactoryPluginInterface,
* The migration entity.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param \Drupal\Core\Language\ConfigurableLanguageManagerInterface $language_manager
* The language manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ConfigFactoryInterface $config_factory) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
$this->config = $config_factory->getEditable($configuration['config_name']);
$this->language_manager = $language_manager;
}
/**
@ -66,7 +77,8 @@ class Config extends DestinationBase implements ContainerFactoryPluginInterface,
$plugin_id,
$plugin_definition,
$migration,
$container->get('config.factory')
$container->get('config.factory'),
$container->get('language_manager')
);
}
@ -74,6 +86,10 @@ class Config extends DestinationBase implements ContainerFactoryPluginInterface,
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
if ($row->hasDestinationProperty('langcode')) {
$this->config = $this->language_manager->getLanguageConfigOverride($row->getDestinationProperty('langcode'), $this->config->getName());
}
foreach ($row->getRawDestination() as $key => $value) {
if (isset($value) || !empty($this->configuration['store null'])) {
$this->config->set(str_replace(Row::PROPERTY_SEPARATOR, '.', $key), $value);

View file

@ -35,10 +35,7 @@ class Get extends ProcessPluginBase {
$properties = is_string($source) ? array($source) : $source;
$return = array();
foreach ($properties as $property) {
if (empty($property)) {
$return[] = $value;
}
else {
if ($property || (string) $property === '0') {
$is_source = TRUE;
if ($property[0] == '@') {
$property = preg_replace_callback('/^(@?)((?:@@)*)([^@]|$)/', function ($matches) use (&$is_source) {
@ -57,7 +54,11 @@ class Get extends ProcessPluginBase {
$return[] = $row->getDestinationProperty($property);
}
}
else {
$return[] = $value;
}
}
if (is_string($source)) {
$this->multiple = is_array($return[0]);
return $return[0];

View file

@ -96,7 +96,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
protected $skipCount = FALSE;
/**
* Flags whether to track changes to incloming data.
* Flags whether to track changes to incoming data.
*
* If TRUE, we will maintain hashed source rows to determine whether incoming
* data has changed.

View file

@ -263,6 +263,15 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
}
$id_map_database_options = $id_map->getDatabase()->getConnectionOptions();
$source_database_options = $this->getDatabase()->getConnectionOptions();
// Special handling for sqlite which deals with files.
if ($id_map_database_options['driver'] === 'sqlite' &&
$source_database_options['driver'] === 'sqlite' &&
$id_map_database_options['database'] != $source_database_options['database']
) {
return FALSE;
}
foreach (array('username', 'password', 'host', 'port', 'namespace', 'driver') as $key) {
if (isset($source_database_options[$key])) {
if ($id_map_database_options[$key] != $source_database_options[$key]) {

View file

@ -107,16 +107,33 @@ class SqlBaseTest extends UnitTestCase {
FALSE,
TRUE,
TRUE,
['username' => 'different_from_map', 'password' => 'different_from_map'],
['username' => 'different_from_source', 'password' => 'different_from_source'],
['driver' => 'mysql', 'username' => 'different_from_map', 'password' => 'different_from_map'],
['driver' => 'mysql', 'username' => 'different_from_source', 'password' => 'different_from_source'],
],
// Returns true because source and id map connection options are the same.
[
TRUE,
TRUE,
TRUE,
['username' => 'same_value', 'password' => 'same_value'],
['username' => 'same_value', 'password' => 'same_value'],
['driver' => 'pgsql', 'username' => 'same_value', 'password' => 'same_value'],
['driver' => 'pgsql', 'username' => 'same_value', 'password' => 'same_value'],
],
// Returns false because driver is sqlite and the databases are not the
// same.
[
FALSE,
TRUE,
TRUE,
['driver' => 'sqlite', 'database' => '1.sqlite', 'username' => '', 'password' => ''],
['driver' => 'sqlite', 'database' => '2.sqlite', 'username' => '', 'password' => ''],
],
// Returns false because driver is not the same.
[
FALSE,
TRUE,
TRUE,
['driver' => 'pgsql', 'username' => 'same_value', 'password' => 'same_value'],
['driver' => 'mysql', 'username' => 'same_value', 'password' => 'same_value'],
],
];
}

View file

@ -49,9 +49,72 @@ class ConfigTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$row->expects($this->once())
->method('hasDestinationProperty')
->will($this->returnValue(FALSE));
$row->expects($this->any())
->method('getRawDestination')
->will($this->returnValue($source));
$destination = new Config(array('config_name' => 'd8_config'), 'd8_config', array('pluginId' => 'd8_config'), $migration, $config_factory);
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
->disableOriginalConstructor()
->getMock();
$language_manager->expects($this->never())
->method('getLanguageConfigOverride')
->with('fr', 'd8_config')
->will($this->returnValue($config));
$destination = new Config(array('config_name' => 'd8_config'), 'd8_config', array('pluginId' => 'd8_config'), $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row);
$this->assertEquals($destination_id, ['d8_config']);
}
/**
* Test the import method.
*/
public function testLanguageImport() {
$source = array(
'langcode' => 'mi',
);
$migration = $this->getMockBuilder('Drupal\migrate\Entity\Migration')
->disableOriginalConstructor()
->getMock();
$config = $this->getMockBuilder('Drupal\Core\Config\Config')
->disableOriginalConstructor()
->getMock();
foreach ($source as $key => $val) {
$config->expects($this->once())
->method('set')
->with($this->equalTo($key), $this->equalTo($val))
->will($this->returnValue($config));
}
$config->expects($this->once())
->method('save');
$config->expects($this->any())
->method('getName')
->willReturn('d8_config');
$config_factory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
$config_factory->expects($this->once())
->method('getEditable')
->with('d8_config')
->will($this->returnValue($config));
$row = $this->getMockBuilder('Drupal\migrate\Row')
->disableOriginalConstructor()
->getMock();
$row->expects($this->once())
->method('hasDestinationProperty')
->will($this->returnValue($source));
$row->expects($this->any())
->method('getRawDestination')
->will($this->returnValue($source));
$row->expects($this->any())
->method('getDestinationProperty')
->will($this->returnValue($source['langcode']));
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
->disableOriginalConstructor()
->getMock();
$language_manager->expects($this->any())
->method('getLanguageConfigOverride')
->with('mi', 'd8_config')
->will($this->returnValue($config));
$destination = new Config(array('config_name' => 'd8_config'), 'd8_config', array('pluginId' => 'd8_config'), $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row);
$this->assertEquals($destination_id, ['d8_config']);
}

View file

@ -82,6 +82,28 @@ class GetTest extends MigrateProcessTestCase {
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($value, array('source_value1', 'source_value2', 'source_value3', 'source_value4'));
}
/**
* Tests the Get plugin when source has integer values.
*/
public function testIntegerValues() {
$this->row->expects($this->exactly(2))
->method('getSourceProperty')
->willReturnOnConsecutiveCalls('val1', 'val2');
$this->plugin->setSource([0 => 0, 1 => 'test']);
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame([0 => 'val1', 1 => 'val2'], $return);
$this->plugin->setSource([FALSE]);
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame([NULL], $return);
$this->plugin->setSource([NULL]);
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame([NULL], $return);
}
}
namespace Drupal\migrate\Plugin\migrate\process;