updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
@@ -13,7 +13,7 @@ use Drupal\Component\Annotation\Plugin;
* \Drupal\migrate\Plugin\migrate\destination\UrlAlias
*
* @see \Drupal\migrate\Plugin\MigrateDestinationInterface
* @see \Drupal\migrate\Plugin\destination\DestinationBase
* @see \Drupal\migrate\Plugin\migrate\destination\DestinationBase
* @see \Drupal\migrate\Plugin\MigrateDestinationPluginManager
* @see \Drupal\migrate\Annotation\MigrateSource
* @see \Drupal\migrate\Annotation\MigrateProcessPlugin
@@ -221,7 +221,9 @@ class MigrateExecutable implements MigrateExecutableInterface {
if ($save) {
try {
$this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROW_SAVE, new MigratePreRowSaveEvent($this->migration, $this->message, $row));
$destination_id_values = $destination->import($row, $id_map->lookupDestinationId($this->sourceIdValues));
$destination_ids = $id_map->lookupDestinationIds($this->sourceIdValues);
$destination_id_values = $destination_ids ? reset($destination_ids) : [];
$destination_id_values = $destination->import($row, $destination_id_values);
$this->getEventDispatcher()->dispatch(MigrateEvents::POST_ROW_SAVE, new MigratePostRowSaveEvent($this->migration, $this->message, $row, $destination_id_values));
if ($destination_id_values) {
// We do not save an idMap entry for config.
@@ -29,7 +29,7 @@ interface MigrateExecutableInterface {
* Usually setting this is not necessary as $process typically starts with
* a 'get'. This is useful only when the $process contains a single
* destination and needs to access a value outside of the source. See
* \Drupal\migrate\Plugin\migrate\process\Iterator::transformKey for an
* \Drupal\migrate\Plugin\migrate\process\SubProcess::transformKey for an
* example.
*
* @throws \Drupal\migrate\MigrateException
@@ -48,7 +48,6 @@ class AnnotatedClassDiscoveryAutomatedProviders extends AnnotatedClassDiscovery
$this->finder = new ClassFinder();
}
/**
* {@inheritdoc}
*/
@@ -11,7 +11,7 @@ use Drupal\migrate\Row;
* Destinations are responsible for persisting source data into the destination
* Drupal.
*
* @see \Drupal\migrate\Plugin\destination\DestinationBase
* @see \Drupal\migrate\Plugin\migrate\destination\DestinationBase
* @see \Drupal\migrate\Plugin\MigrateDestinationPluginManager
* @see \Drupal\migrate\Annotation\MigrateDestination
* @see plugin_api
@@ -10,7 +10,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
* Plugin manager for migrate destination plugins.
*
* @see \Drupal\migrate\Plugin\MigrateDestinationInterface
* @see \Drupal\migrate\Plugin\destination\DestinationBase
* @see \Drupal\migrate\Plugin\migrate\destination\DestinationBase
* @see \Drupal\migrate\Annotation\MigrateDestination
* @see plugin_api
*
@@ -103,7 +103,6 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
*/
public function importedCount();
/**
* Returns a count of items which are marked as needing update.
*
@@ -197,7 +196,7 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
* The source identifier keyed values of the record, e.g. ['nid' => 5], or
* an empty array on failure.
*/
public function lookupSourceID(array $destination_id_values);
public function lookupSourceId(array $destination_id_values);
/**
* Looks up the destination identifier corresponding to a source key.
@@ -9,11 +9,16 @@ use Drupal\migrate\Row;
/**
* An interface for migrate process plugins.
*
* A process plugin can use any number of methods instead of (but not in
* addition to) transform with the same arguments and then the plugin
* configuration needs to provide the name of the method to be called via the
* "method" key. See \Drupal\migrate\Plugin\migrate\process\SkipOnEmpty and
* migrate.migration.d6_field_instance_widget_settings.yml for examples.
* A process plugin will typically implement the transform() method to perform
* its work. However, it is possible instead for a process plugin to use any
* number of methods, thus offering different alternatives ways of processing.
* In this case, the transform() method should not be implemented, and the
* plugin configuration must provide the name of the method to be called via the
* "method" key. Each method must have the same signature as transform().
* The base class \Drupal\migrate\ProcessPluginBase takes care of implementing
* transform() and calling the configured method. See
* \Drupal\migrate\Plugin\migrate\process\SkipOnEmpty and
* d6_field_instance_widget_settings.yml for examples.
*
* @see \Drupal\migrate\Plugin\MigratePluginManager
* @see \Drupal\migrate\ProcessPluginBase
@@ -87,10 +87,10 @@ interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspection
*
* Additional custom keys/values that are not part of field storage
* definition can be added as shown below. The most common setting
* passed along to the ID definition is 'alias', used by the SqlBase source
* plugin in order to distinguish between ambiguous column names - for
* example, when a SQL source query joins two tables with the same column
* names.
* passed along to the ID definition is table 'alias', used by the SqlBase
* source plugin in order to distinguish between ambiguous column names -
* for example, when a SQL source query joins two tables with the same
* column names.
* @code
* return [
* 'nid' => [
@@ -410,7 +410,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
*/
public function getDestinationPlugin($stub_being_requested = FALSE) {
if ($stub_being_requested && !empty($this->destination['no_stub'])) {
throw new MigrateSkipRowException();
throw new MigrateSkipRowException('Stub requested but not made because no_stub configuration is set.');
}
if (!isset($this->destinationPlugin)) {
$this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);
@@ -554,7 +554,6 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
return $this;
}
/**
* {@inheritdoc}
*/
@@ -620,19 +619,22 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
}
/**
* Find migration dependencies from the migration and the iterator plugins.
* Find migration dependencies from migration_lookup and sub_process plugins.
*
* @param array $process
* A process configuration array.
*
* @param $process
* @return array
* The migration dependencies.
*/
protected function findMigrationDependencies($process) {
$return = [];
foreach ($this->getProcessNormalized($process) as $process_pipeline) {
foreach ($process_pipeline as $plugin_configuration) {
if ($plugin_configuration['plugin'] == 'migration') {
if (in_array($plugin_configuration['plugin'], ['migration', 'migration_lookup'], TRUE)) {
$return = array_merge($return, (array) $plugin_configuration['migration']);
}
if ($plugin_configuration['plugin'] == 'sub_process') {
if (in_array($plugin_configuration['plugin'], ['iterator', 'sub_process'], TRUE)) {
$return = array_merge($return, $this->findMigrationDependencies($plugin_configuration['process']));
}
}
@@ -83,7 +83,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
// This gets rid of migrations which try to use a non-existent source
// plugin. The common case for this is if the source plugin has, or
// specifies, a non-existent provider.
$only_with_source_discovery = new NoSourcePluginDecorator($yaml_discovery);
$only_with_source_discovery = new NoSourcePluginDecorator($yaml_discovery);
// This gets rid of migrations with explicit providers set if one of the
// providers do not exist before we try to use a potentially non-existing
// deriver. This is a rare case.
@@ -160,7 +160,6 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
return $plugin_ids;
}
/**
* {@inheritdoc}
*/
@@ -12,7 +12,7 @@ use Drupal\migrate\Plugin\RequirementsInterface;
/**
* Base class for migrate destination classes.
*
* Migrate destination plugins perfom the import operation of the migration.
* Migrate destination plugins perform the import operation of the migration.
* Destination plugins extend this abstract base class. A destination plugin
* must implement at least fields(), getIds() and import() methods. Destination
* plugins can also support rollback operations. For more
@@ -72,7 +72,7 @@ class EntityConfigBase extends Entity {
/**
* The configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface;
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
@@ -148,7 +148,7 @@ class EntityContentBase extends Entity implements HighestIdInterface {
}
$ids = $this->save($entity, $old_destination_id_values);
if (!empty($this->configuration['translations'])) {
if ($this->isTranslationDestination()) {
$ids[] = $entity->language()->getId();
}
return $ids;
@@ -181,12 +181,15 @@ class EntityContentBase extends Entity implements HighestIdInterface {
* {@inheritdoc}
*/
public function getIds() {
$ids = [];
$id_key = $this->getKey('id');
$ids[$id_key] = $this->getDefinitionFromEntity($id_key);
if ($this->isTranslationDestination()) {
if (!$langcode_key = $this->getKey('langcode')) {
throw new MigrateException('This entity type does not support translation.');
$langcode_key = $this->getKey('langcode');
if (!$langcode_key) {
throw new MigrateException(sprintf('The "%s" entity type does not support translations.', $this->storage->getEntityTypeId()));
}
$ids[$langcode_key] = $this->getDefinitionFromEntity($langcode_key);
}
@@ -202,8 +205,8 @@ class EntityContentBase extends Entity implements HighestIdInterface {
* @param \Drupal\migrate\Row $row
* The row object to update from.
*
* @return \Drupal\Core\Entity\EntityInterface|null
* An updated entity, or NULL if it's the same as the one passed in.
* @return \Drupal\Core\Entity\EntityInterface
* An updated entity from row values.
*/
protected function updateEntity(EntityInterface $entity, Row $row) {
$empty_destinations = $row->getEmptyDestinationProperties();
@@ -160,7 +160,9 @@ class EntityRevision extends EntityContentBase {
$entity->enforceIsNew(FALSE);
$entity->setNewRevision(TRUE);
}
$this->updateEntity($entity, $row);
// We need to update the entity, so that the destination row IDs are
// correct.
$entity = $this->updateEntity($entity, $row);
$entity->isDefaultRevision(FALSE);
return $entity;
}
@@ -177,10 +179,23 @@ class EntityRevision extends EntityContentBase {
* {@inheritdoc}
*/
public function getIds() {
if ($key = $this->getKey('revision')) {
return [$key => $this->getDefinitionFromEntity($key)];
$ids = [];
$revision_key = $this->getKey('revision');
if (!$revision_key) {
throw new MigrateException(sprintf('The "%s" entity type does not support revisions.', $this->storage->getEntityTypeId()));
}
throw new MigrateException('This entity type does not support revisions.');
$ids[$revision_key] = $this->getDefinitionFromEntity($revision_key);
if ($this->isTranslationDestination()) {
$langcode_key = $this->getKey('langcode');
if (!$langcode_key) {
throw new MigrateException(sprintf('The "%s" entity type does not support translations.', $this->storage->getEntityTypeId()));
}
$ids[$langcode_key] = $this->getDefinitionFromEntity($langcode_key);
}
return $ids;
}
/**
@@ -48,7 +48,7 @@ class NullIdMap extends PluginBase implements MigrateIdMapInterface {
/**
* {@inheritdoc}
*/
public function lookupSourceID(array $destination_id_values) {
public function lookupSourceId(array $destination_id_values) {
return [];
}
@@ -2,7 +2,7 @@
namespace Drupal\migrate\Plugin\migrate\id_map;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\DatabaseException;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
@@ -161,6 +161,18 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$this->migration = $migration;
$this->eventDispatcher = $event_dispatcher;
$this->message = new MigrateMessage();
if (!isset($this->database)) {
$this->database = \Drupal::database();
}
// Default generated table names, limited to 63 characters.
$machine_name = str_replace(':', '__', $this->migration->id());
$prefix_length = strlen($this->database->tablePrefix());
$this->mapTableName = 'migrate_map_' . mb_strtolower($machine_name);
$this->mapTableName = mb_substr($this->mapTableName, 0, 63 - $prefix_length);
$this->messageTableName = 'migrate_message_' . mb_strtolower($machine_name);
$this->messageTableName = mb_substr($this->messageTableName, 0, 63 - $prefix_length);
}
/**
@@ -187,7 +199,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
* @return string
* An hash containing the hashed values of the source identifiers.
*/
public function getSourceIDsHash(array $source_id_values) {
public function getSourceIdsHash(array $source_id_values) {
// When looking up the destination ID we require an array with both the
// source key and value, e.g. ['nid' => 41]. In this case, $source_id_values
// need to be ordered the same order as $this->sourceIdFields().
@@ -246,7 +258,6 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
* The map table name.
*/
public function mapTableName() {
$this->init();
return $this->mapTableName;
}
@@ -257,7 +268,6 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
* The message table name.
*/
public function messageTableName() {
$this->init();
return $this->messageTableName;
}
@@ -278,9 +288,6 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
* The database connection object.
*/
public function getDatabase() {
if (!isset($this->database)) {
$this->database = \Drupal::database();
}
$this->init();
return $this->database;
}
@@ -291,13 +298,6 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
protected function init() {
if (!$this->initialized) {
$this->initialized = TRUE;
// Default generated table names, limited to 63 characters.
$machine_name = str_replace(':', '__', $this->migration->id());
$prefix_length = strlen($this->getDatabase()->tablePrefix());
$this->mapTableName = 'migrate_map_' . Unicode::strtolower($machine_name);
$this->mapTableName = Unicode::substr($this->mapTableName, 0, 63 - $prefix_length);
$this->messageTableName = 'migrate_message_' . Unicode::strtolower($machine_name);
$this->messageTableName = Unicode::substr($this->messageTableName, 0, 63 - $prefix_length);
$this->ensureTables();
}
}
@@ -491,7 +491,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
public function getRowBySource(array $source_id_values) {
$query = $this->getDatabase()->select($this->mapTableName(), 'map')
->fields('map');
$query->condition(static::SOURCE_IDS_HASH, $this->getSourceIDsHash($source_id_values));
$query->condition(static::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
$result = $query->execute();
return $result->fetchAssoc();
}
@@ -528,7 +528,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
/**
* {@inheritdoc}
*/
public function lookupSourceID(array $destination_id_values) {
public function lookupSourceId(array $destination_id_values) {
$source_id_fields = $this->sourceIdFields();
$query = $this->getDatabase()->select($this->mapTableName(), 'map');
foreach ($source_id_fields as $source_field_name => $idmap_field_name) {
@@ -562,9 +562,13 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$conditions = [];
foreach ($this->sourceIdFields() as $field_name => $db_field) {
if ($is_associative) {
// Associative $source_id_values can have fields out of order.
if (isset($source_id_values[$field_name])) {
$conditions[$db_field] = $source_id_values[$field_name];
// Ensure to handle array elements with a NULL value.
if (array_key_exists($field_name, $source_id_values)) {
// Associative $source_id_values can have fields out of order.
if (isset($source_id_values[$field_name])) {
// Only add a condition if the value is not NULL.
$conditions[$db_field] = $source_id_values[$field_name];
}
unset($source_id_values[$field_name]);
}
}
@@ -579,14 +583,15 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
}
if (!empty($source_id_values)) {
throw new MigrateException("Extra unknown items in source IDs");
$var_dump = var_export($source_id_values, TRUE);
throw new MigrateException(sprintf("Extra unknown items in source IDs: %s", $var_dump));
}
$query = $this->getDatabase()->select($this->mapTableName(), 'map')
->fields('map', $this->destinationIdFields());
if (count($this->sourceIdFields()) === count($conditions)) {
// Optimization: Use the primary key.
$query->condition(self::SOURCE_IDS_HASH, $this->getSourceIDsHash(array_values($conditions)));
$query->condition(self::SOURCE_IDS_HASH, $this->getSourceIdsHash(array_values($conditions)));
}
else {
foreach ($conditions as $db_field => $value) {
@@ -636,7 +641,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
if ($this->migration->getTrackLastImported()) {
$fields['last_imported'] = time();
}
$keys = [static::SOURCE_IDS_HASH => $this->getSourceIDsHash($source_id_values)];
$keys = [static::SOURCE_IDS_HASH => $this->getSourceIdsHash($source_id_values)];
// Notify anyone listening of the map row we're about to save.
$this->eventDispatcher->dispatch(MigrateEvents::MAP_SAVE, new MigrateMapSaveEvent($this, $fields));
$this->getDatabase()->merge($this->mapTableName())
@@ -655,7 +660,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
return;
}
}
$fields[static::SOURCE_IDS_HASH] = $this->getSourceIDsHash($source_id_values);
$fields[static::SOURCE_IDS_HASH] = $this->getSourceIdsHash($source_id_values);
$fields['level'] = $level;
$fields['message'] = $message;
$this->getDatabase()->insert($this->messageTableName())
@@ -674,7 +679,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$query = $this->getDatabase()->select($this->messageTableName(), 'msg')
->fields('msg');
if ($source_id_values) {
$query->condition(static::SOURCE_IDS_HASH, $this->getSourceIDsHash($source_id_values));
$query->condition(static::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
}
if ($level) {
@@ -696,21 +701,17 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
* {@inheritdoc}
*/
public function processedCount() {
return (int) $this->getDatabase()->select($this->mapTableName())
->countQuery()
->execute()
->fetchField();
return $this->countHelper(NULL, $this->mapTableName());
}
/**
* {@inheritdoc}
*/
public function importedCount() {
return (int) $this->getDatabase()->select($this->mapTableName())
->condition('source_row_status', [MigrateIdMapInterface::STATUS_IMPORTED, MigrateIdMapInterface::STATUS_NEEDS_UPDATE], 'IN')
->countQuery()
->execute()
->fetchField();
return $this->countHelper([
MigrateIdMapInterface::STATUS_IMPORTED,
MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
]);
}
/**
@@ -737,20 +738,28 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
/**
* Counts records in a table.
*
* @param int $status
* An integer for the source_row_status column.
* @param int|array $status
* (optional) Status code(s) to filter the source_row_status column.
* @param string $table
* (optional) The table to work. Defaults to NULL.
*
* @return int
* The number of records.
*/
protected function countHelper($status, $table = NULL) {
$query = $this->getDatabase()->select($table ?: $this->mapTableName());
protected function countHelper($status = NULL, $table = NULL) {
// Use database directly to avoid creating tables.
$query = $this->database->select($table ?: $this->mapTableName());
if (isset($status)) {
$query->condition('source_row_status', $status);
$query->condition('source_row_status', $status, is_array($status) ? 'IN' : '=');
}
return (int) $query->countQuery()->execute()->fetchField();
try {
$count = (int) $query->countQuery()->execute()->fetchField();
}
catch (DatabaseException $e) {
// The table does not exist, therefore there are no records.
$count = 0;
}
return $count;
}
/**
@@ -763,13 +772,13 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
if (!$messages_only) {
$map_query = $this->getDatabase()->delete($this->mapTableName());
$map_query->condition(static::SOURCE_IDS_HASH, $this->getSourceIDsHash($source_id_values));
$map_query->condition(static::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
// Notify anyone listening of the map row we're about to delete.
$this->eventDispatcher->dispatch(MigrateEvents::MAP_DELETE, new MigrateMapDeleteEvent($this, $source_id_values));
$map_query->execute();
}
$message_query = $this->getDatabase()->delete($this->messageTableName());
$message_query->condition(static::SOURCE_IDS_HASH, $this->getSourceIDsHash($source_id_values));
$message_query->condition(static::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
$message_query->execute();
}
@@ -779,7 +788,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
public function deleteDestination(array $destination_id_values) {
$map_query = $this->getDatabase()->delete($this->mapTableName());
$message_query = $this->getDatabase()->delete($this->messageTableName());
$source_id_values = $this->lookupSourceID($destination_id_values);
$source_id_values = $this->lookupSourceId($destination_id_values);
if (!empty($source_id_values)) {
foreach ($this->destinationIdFields() as $field_name => $destination_id) {
$map_query->condition($destination_id, $destination_id_values[$field_name]);
@@ -788,7 +797,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$this->eventDispatcher->dispatch(MigrateEvents::MAP_DELETE, new MigrateMapDeleteEvent($this, $source_id_values));
$map_query->execute();
$message_query->condition(static::SOURCE_IDS_HASH, $this->getSourceIDsHash($source_id_values));
$message_query->condition(static::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
$message_query->execute();
}
}
@@ -976,8 +985,9 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
// Get the highest id from the list of map tables.
$ids = [0];
foreach ($map_tables as $map_table) {
// If the map_table does not exist then continue on to the next map_table.
if (!$this->getDatabase()->schema()->tableExists($map_table)) {
break;
continue;
}
$query = $this->getDatabase()->select($map_table, 'map')
@@ -49,11 +49,21 @@ class Callback extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (is_callable($this->configuration['callable'])) {
$value = call_user_func($this->configuration['callable'], $value);
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
if (!isset($configuration['callable'])) {
throw new \InvalidArgumentException('The "callable" must be set.');
}
return $value;
elseif (!is_callable($configuration['callable'])) {
throw new \InvalidArgumentException('The "callable" must be a valid function or method.');
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
return call_user_func($this->configuration['callable'], $value);
}
}
@@ -6,7 +6,6 @@ use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use GuzzleHttp\Client;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -19,8 +18,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* - destination URI, e.g. 'public://images/foo.img'
*
* Available configuration keys:
* - rename: (optional) If set, a unique destination URI is generated. If not
* set, the destination URI will be overwritten if it exists.
* - file_exists: (optional) Replace behavior when the destination file already
* exists:
* - 'replace' - (default) Replace the existing file.
* - 'rename' - Append _{incrementing number} until the filename is
* unique.
* - 'use existing' - Do nothing and return FALSE.
* - guzzle_options: (optional)
* @link http://docs.guzzlephp.org/en/latest/request-options.html Array of request options for Guzzle. @endlink
*
@@ -42,7 +45,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* source:
* - source_url
* - destination_uri
* rename: true
* file_exists: rename
* @endcode
*
* This will download source_url to destination_uri and ensure that the
@@ -53,7 +56,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* id = "download"
* )
*/
class Download extends ProcessPluginBase implements ContainerFactoryPluginInterface {
class Download extends FileProcessBase implements ContainerFactoryPluginInterface {
/**
* The file system service.
@@ -85,7 +88,6 @@ class Download extends ProcessPluginBase implements ContainerFactoryPluginInterf
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, FileSystemInterface $file_system, Client $http_client) {
$configuration += [
'rename' => FALSE,
'guzzle_options' => [],
];
parent::__construct($configuration, $plugin_id, $plugin_definition);
@@ -118,10 +120,12 @@ class Download extends ProcessPluginBase implements ContainerFactoryPluginInterf
list($source, $destination) = $value;
// Modify the destination filename if necessary.
$replace = !empty($this->configuration['rename']) ?
FILE_EXISTS_RENAME :
FILE_EXISTS_REPLACE;
$final_destination = file_destination($destination, $replace);
$final_destination = file_destination($destination, $this->configuration['file_exists']);
// Reuse if file exists.
if (!$final_destination) {
return $destination;
}
// Try opening the file first, to avoid calling file_prepare_directory()
// unnecessarily. We're suppressing fopen() errors because we want to try
@@ -9,7 +9,6 @@ use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -26,10 +25,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* Available configuration keys:
* - move: (optional) Boolean, if TRUE, move the file, otherwise copy the file.
* Defaults to FALSE.
* - rename: (optional) Boolean, if TRUE, rename the file by appending a number
* until the name is unique. Defaults to FALSE.
* - reuse: (optional) Boolean, if TRUE, reuse the current file in its existing
* location rather than move/copy/rename the file. Defaults to FALSE.
* - file_exists: (optional) Replace behavior when the destination file already
* exists:
* - 'replace' - (default) Replace the existing file.
* - 'rename' - Append _{incrementing number} until the filename is
* unique.
* - 'use existing' - Do nothing and return FALSE.
*
* Examples:
*
@@ -48,7 +49,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* id = "file_copy"
* )
*/
class FileCopy extends ProcessPluginBase implements ContainerFactoryPluginInterface {
class FileCopy extends FileProcessBase implements ContainerFactoryPluginInterface {
/**
* The stream wrapper manager service.
@@ -90,8 +91,6 @@ class FileCopy extends ProcessPluginBase implements ContainerFactoryPluginInterf
public function __construct(array $configuration, $plugin_id, array $plugin_definition, StreamWrapperManagerInterface $stream_wrappers, FileSystemInterface $file_system, MigrateProcessInterface $download_plugin) {
$configuration += [
'move' => FALSE,
'rename' => FALSE,
'reuse' => FALSE,
];
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->streamWrapperManager = $stream_wrappers;
@@ -109,7 +108,7 @@ class FileCopy extends ProcessPluginBase implements ContainerFactoryPluginInterf
$plugin_definition,
$container->get('stream_wrapper_manager'),
$container->get('file_system'),
$container->get('plugin.manager.migrate.process')->createInstance('download')
$container->get('plugin.manager.migrate.process')->createInstance('download', $configuration)
);
}
@@ -150,7 +149,7 @@ class FileCopy extends ProcessPluginBase implements ContainerFactoryPluginInterf
}
}
$final_destination = $this->writeFile($source, $destination, $this->getOverwriteMode());
$final_destination = $this->writeFile($source, $destination, $this->configuration['file_exists']);
if ($final_destination) {
return $final_destination;
}
@@ -181,24 +180,6 @@ class FileCopy extends ProcessPluginBase implements ContainerFactoryPluginInterf
return $function($source, $destination, $replace);
}
/**
* Determines how to handle file conflicts.
*
* @return int
* FILE_EXISTS_REPLACE (default), FILE_EXISTS_RENAME, or FILE_EXISTS_ERROR
* depending on the current configuration.
*/
protected function getOverwriteMode() {
if (!empty($this->configuration['rename'])) {
return FILE_EXISTS_RENAME;
}
if (!empty($this->configuration['reuse'])) {
return FILE_EXISTS_ERROR;
}
return FILE_EXISTS_REPLACE;
}
/**
* Returns the directory component of a URI or path.
*
@@ -0,0 +1,59 @@
<?php
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
/**
* Provides functionality for file process plugins.
*
* Available configuration keys:
* - file_exists: (optional) Replace behavior when the destination file already
* exists:
* - 'replace' - (default) Replace the existing file.
* - 'rename' - Append _{incrementing number} until the filename is
* unique.
* - 'use existing' - Do nothing and return FALSE.
*/
abstract class FileProcessBase extends ProcessPluginBase {
/**
* Constructs a file process plugin.
*
* @param array $configuration
* The plugin configuration.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
if (array_key_exists('file_exists', $configuration)) {
switch ($configuration['file_exists']) {
case 'use existing':
$configuration['file_exists'] = FILE_EXISTS_ERROR;
break;
case 'rename':
$configuration['file_exists'] = FILE_EXISTS_RENAME;
break;
default:
$configuration['file_exists'] = FILE_EXISTS_REPLACE;
}
}
if (array_key_exists('reuse', $configuration)) {
@trigger_error("Using the key 'reuse' is deprecated, use 'file_exists' => 'use existing' instead. See https://www.drupal.org/node/2981389.", E_USER_DEPRECATED);
if (!empty($configuration['reuse'])) {
$configuration['file_exists'] = FILE_EXISTS_ERROR;
}
}
if (array_key_exists('rename', $configuration)) {
@trigger_error("Using the key 'rename' is deprecated, use 'file_exists' => 'rename' instead. See https://www.drupal.org/node/2981389.", E_USER_DEPRECATED);
if (!empty($configuration['rename'])) {
$configuration['file_exists'] = FILE_EXISTS_RENAME;
}
}
$configuration += ['file_exists' => FILE_EXISTS_REPLACE];
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
}
@@ -70,8 +70,8 @@ use Drupal\migrate\Row;
* property bar. foo configuration is included for illustration purposes.
*
* Because of this, if the source or destination property actually starts with a
* @, that character must be escaped with @@.
* The referenced property becomes, for example, @@@foo.
* "@", that character must be escaped with "@@". The referenced property
* becomes, for example, "@@@foo".
*
* @code
* process:
@@ -6,7 +6,6 @@ use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\migrate\MigrateException;
use Drupal\Component\Utility\Unicode;
/**
* This plugin ensures the source value is unique.
@@ -56,7 +55,7 @@ abstract class MakeUniqueBase extends ProcessPluginBase {
throw new MigrateException('The character length configuration key should be an integer. Omit this key to capture the entire string.');
}
// Use optional start or length to return a portion of the unique value.
$value = Unicode::substr($value, $start, $length);
$value = mb_substr($value, $start, $length);
$new_value = $value;
while ($this->exists($new_value)) {
$new_value = $value . $postfix . $i++;
@@ -134,7 +134,7 @@ class MakeUniqueEntityField extends MakeUniqueBase implements ContainerFactoryPl
$idMap = $this->migration->getIdMap();
foreach ($query->execute() as $id) {
$dest_id_values[$this->configuration['field']] = $id;
if ($idMap->lookupSourceID($dest_id_values)) {
if ($idMap->lookupSourceId($dest_id_values)) {
return TRUE;
}
}
@@ -97,7 +97,7 @@ class MenuLinkParent extends ProcessPluginBase implements ContainerFactoryPlugin
}
}
}
throw new MigrateSkipRowException();
throw new MigrateSkipRowException(sprintf("No parent link found for plid '%d' in menu '%s'.", $parent_id, $value[0]));
}
}
@@ -3,6 +3,7 @@
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\Variable;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
@@ -140,7 +141,7 @@ class StaticMap extends ProcessPluginBase {
return $this->configuration['default_value'];
}
if (empty($this->configuration['bypass'])) {
throw new MigrateSkipRowException();
throw new MigrateSkipRowException(sprintf("No static mapping found for '%s' and no default value provided for destination '%s'.", Variable::export($value), $destination_property));
}
else {
return $value;
@@ -6,14 +6,12 @@ use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\migrate\MigrateException;
use Drupal\Component\Utility\Unicode;
/**
* Returns a substring of the input value.
*
* The substr process plugin returns the portion of the input value specified by
* the start and length parameters. This is a wrapper around
* \Drupal\Component\Utility\Unicode::substr().
* the start and length parameters. This is a wrapper around mb_substr().
*
* Available configuration keys:
* - start: (optional) The returned string will start this many characters after
@@ -85,7 +83,7 @@ class Substr extends ProcessPluginBase {
}
// Use optional start or length to return a portion of $value.
$new_value = Unicode::substr($value, $start, $length);
$new_value = mb_substr($value, $start, $length);
return $new_value;
}
@@ -19,7 +19,8 @@ namespace Drupal\migrate\Plugin\migrate\source;
* elements, with values of 'user' and 'image', respectively.
*
* @MigrateSource(
* id = "empty"
* id = "empty",
* source_module = "migrate"
* )
*/
class EmptySource extends SourcePluginBase {
@@ -24,8 +24,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* - target: (optional) The database target name. Defaults to 'default'.
* - batch_size: (optional) Number of records to fetch from the database during
* each batch. If omitted, all records are fetched in a single query.
* - ignore_map: (optional) Source data is joined to the map table by default.
* If set to TRUE, the map table will not be joined.
* - ignore_map: (optional) Source data is joined to the map table by default to
* improve migration performance. If set to TRUE, the map table will not be
* joined. Using expressions in the query may result in column aliases in the
* JOIN clause which would be invalid SQL. If you run into this, set
* ignore_map to TRUE.
*
* For other optional configuration keys inherited from the parent class, refer
* to \Drupal\migrate\Plugin\migrate\source\SourcePluginBase.
@@ -4,5 +4,5 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- node
- migrate
- drupal:node
- drupal:migrate
@@ -4,4 +4,4 @@ description: 'Provides test fixtures for testing high water marks.'
package: Testing
core: 8.x
dependencies:
- migrate
- drupal:migrate
@@ -4,4 +4,4 @@ description: 'Provides a database table and records for SQL import with batch te
package: Testing
core: 8.x
dependencies:
- migrate
- drupal:migrate
@@ -4,4 +4,4 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- migrate
- drupal:migrate
@@ -41,7 +41,7 @@ class DownloadFunctionalTest extends BrowserTestBase {
'uri' => [
'plugin' => 'download',
'source' => ['url', 'uri'],
]
],
],
'destination' => [
'plugin' => 'entity:file',
@@ -34,7 +34,7 @@ class MigrateConfigRollbackTest extends MigrateTestBase {
$ids = [
'id' =>
[
'type' => 'string'
'type' => 'string',
],
];
$definition = [
@@ -100,12 +100,12 @@ class MigrateConfigRollbackTest extends MigrateTestBase {
$ids = [
'id' =>
[
'type' => 'string'
'type' => 'string',
],
'language' =>
[
'type' => 'string'
]
'type' => 'string',
],
];
$definition = [
'id' => 'i18n_config',
@@ -83,14 +83,14 @@ class MigrateRollbackEntityConfigTest extends MigrateTestBase {
'name' => '1',
'language' => 'fr',
'property' => 'name',
'translation' => 'fr - categories'
'translation' => 'fr - categories',
],
[
'id' => '2',
'name' => '2',
'language' => 'fr',
'property' => 'name',
'translation' => 'fr - tags'
'translation' => 'fr - tags',
],
];
$ids = [
@@ -106,7 +106,7 @@ class MigrateRollbackEntityConfigTest extends MigrateTestBase {
'ids' => $ids,
'constants' => [
'name' => 'name',
]
],
],
'process' => [
'vid' => 'id',
@@ -0,0 +1,131 @@
<?php
namespace Drupal\Tests\migrate\Kernel\Plugin;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\Node;
use Drupal\Tests\migrate\Kernel\MigrateTestBase;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
/**
* Tests the EntityRevision destination plugin.
*
* @group migrate
*/
class EntityRevisionTest extends MigrateTestBase {
use ContentTypeCreationTrait;
/**
* {@inheritdoc}
*/
public static $modules = [
'content_translation',
'field',
'filter',
'language',
'node',
'system',
'text',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig('node');
$this->installSchema('node', ['node_access']);
$this->installEntitySchema('node');
$this->installEntitySchema('user');
}
/**
* Tests that EntityRevision correctly handles revision translations.
*/
public function testRevisionTranslation() {
ConfigurableLanguage::createFromLangcode('fr')->save();
/** @var \Drupal\node\NodeInterface $node */
$node = Node::create([
'type' => $this->createContentType()->id(),
'title' => 'Default 1',
]);
$node->addTranslation('fr', [
'title' => 'French 1',
]);
$node->save();
$node->setNewRevision();
$node->setTitle('Default 2');
$node->getTranslation('fr')->setTitle('French 2');
$node->save();
$migration = [
'source' => [
'plugin' => 'embedded_data',
'data_rows' => [
[
'nid' => $node->id(),
'vid' => $node->getRevisionId(),
'langcode' => 'fr',
'title' => 'Titre nouveau, tabarnak!',
],
],
'ids' => [
'nid' => [
'type' => 'integer',
],
'vid' => [
'type' => 'integer',
],
'langcode' => [
'type' => 'string',
],
],
],
'process' => [
'nid' => 'nid',
'vid' => 'vid',
'langcode' => 'langcode',
'title' => 'title',
],
'destination' => [
'plugin' => 'entity_revision:node',
'translations' => TRUE,
],
];
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = $this->container
->get('plugin.manager.migration')
->createStubMigration($migration);
$this->executeMigration($migration);
// The entity_revision destination uses the revision ID and langcode as its
// keys (the langcode is only used if the destination is configured for
// translation), so we should be able to look up the source IDs by revision
// ID and langcode.
$source_ids = $migration->getIdMap()->lookupSourceID([
'vid' => $node->getRevisionId(),
'langcode' => 'fr',
]);
$this->assertNotEmpty($source_ids);
$this->assertSame($node->id(), $source_ids['nid']);
$this->assertSame($node->getRevisionId(), $source_ids['vid']);
$this->assertSame('fr', $source_ids['langcode']);
// Confirm the french revision was used in the migration, instead of the
// default revision.
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = \Drupal::entityTypeManager();
$revision = $entity_type_manager->getStorage('node')->loadRevision(1);
$this->assertSame('Default 1', $revision->label());
$this->assertSame('French 1', $revision->getTranslation('fr')->label());
$revision = $entity_type_manager->getStorage('node')->loadRevision(2);
$this->assertSame('Default 2', $revision->label());
$this->assertSame('Titre nouveau, tabarnak!', $revision->getTranslation('fr')->label());
}
}
@@ -3,6 +3,7 @@
namespace Drupal\Tests\migrate\Kernel\Plugin;
use Drupal\Core\Database\Database;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
@@ -16,6 +17,8 @@ use Drupal\migrate\Plugin\RequirementsInterface;
*/
class MigrationPluginListTest extends KernelTestBase {
use EntityReferenceTestTrait;
/**
* {@inheritdoc}
*/
@@ -30,6 +33,7 @@ class MigrationPluginListTest extends KernelTestBase {
'book',
'comment',
'contact',
'content_translation',
'dblog',
'field',
'file',
@@ -41,6 +45,7 @@ class MigrationPluginListTest extends KernelTestBase {
'menu_link_content',
'menu_ui',
'node',
'options',
'path',
'search',
'shortcut',
@@ -59,6 +64,11 @@ class MigrationPluginListTest extends KernelTestBase {
* @covers ::getDefinitions
*/
public function testGetDefinitions() {
// Create an entity reference field to make sure that migrations derived by
// EntityReferenceTranslationDeriver do not get discovered without
// migrate_drupal enabled.
$this->createEntityReferenceField('user', 'user', 'field_entity_reference', 'Entity Reference', 'node');
// Make sure retrieving all the core migration plugins does not throw any
// errors.
$migration_plugins = $this->container->get('plugin.manager.migration')->getDefinitions();
@@ -131,6 +141,11 @@ class MigrationPluginListTest extends KernelTestBase {
$migration_plugins = $this->container->get('plugin.manager.migration')->getDefinitions();
// All the plugins provided by core depend on migrate_drupal.
$this->assertNotEmpty($migration_plugins);
// Test that migrations derived by EntityReferenceTranslationDeriver are
// discovered now that migrate_drupal is enabled.
$this->assertArrayHasKey('d6_entity_reference_translation:user__user', $migration_plugins);
$this->assertArrayHasKey('d7_entity_reference_translation:user__user', $migration_plugins);
}
}
@@ -31,16 +31,12 @@ class MigrationProvidersExistTest extends MigrateDrupalTestBase {
public function testProvidersExist() {
$this->enableAllModules();
/** @var \Drupal\migrate\Plugin\MigrationPluginManager $plugin_manager */
$plugin_manager = $this->container->get('plugin.manager.migration');
/** @var \Drupal\migrate\Plugin\MigrateSourcePluginManager $plugin_manager */
$plugin_manager = $this->container->get('plugin.manager.migrate.source');
// Instantiate all migrations.
$migrations = array_keys($plugin_manager->getDefinitions());
$migrations = $plugin_manager->createInstances($migrations);
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
foreach ($migrations as $migration) {
$this->assertInternalType('string', $migration->getSourcePlugin()->getSourceModule());
foreach ($plugin_manager->getDefinitions() as $definition) {
$id = $definition['id'];
$this->assertArrayHasKey('source_module', $definition, "No source_module property in '$id'");
}
}
@@ -3,6 +3,8 @@
namespace Drupal\Tests\migrate\Kernel\Plugin;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateSkipRowException;
/**
* Tests the migration plugin.
@@ -27,6 +29,17 @@ class MigrationTest extends KernelTestBase {
$this->assertEquals([], $migration->getProcessPlugins([]));
}
/**
* Tests Migration::getProcessPlugins() throws an exception.
*
* @covers ::getProcessPlugins
*/
public function testGetProcessPluginsException() {
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
$this->setExpectedException(MigrateException::class, 'Invalid process configuration for foobar');
$migration->getProcessPlugins(['foobar' => ['plugin' => 'get']]);
}
/**
* Tests Migration::getMigrationDependencies()
*
@@ -39,7 +52,7 @@ class MigrationTest extends KernelTestBase {
'f1' => 'bar',
'f2' => [
'plugin' => 'migration',
'migration' => 'm1'
'migration' => 'm1',
],
'f3' => [
'plugin' => 'sub_process',
@@ -50,10 +63,32 @@ class MigrationTest extends KernelTestBase {
],
],
],
'f4' => [
'plugin' => 'migration_lookup',
'migration' => 'm3',
],
'f5' => [
'plugin' => 'sub_process',
'process' => [
'target_id' => [
'plugin' => 'migration_lookup',
'migration' => 'm4',
],
],
],
'f6' => [
'plugin' => 'iterator',
'process' => [
'target_id' => [
'plugin' => 'migration_lookup',
'migration' => 'm5',
],
],
],
],
];
$migration = $plugin_manager->createStubMigration($plugin_definition);
$this->assertSame(['required' => [], 'optional' => ['m1', 'm2']], $migration->getMigrationDependencies());
$this->assertSame(['required' => [], 'optional' => ['m1', 'm2', 'm3', 'm4', 'm5']], $migration->getMigrationDependencies());
}
/**
@@ -81,4 +116,15 @@ class MigrationTest extends KernelTestBase {
$this->assertEquals(TRUE, $migration->isTrackLastImported());
}
/**
* Tests Migration::getDestinationPlugin()
*
* @covers ::getDestinationPlugin
*/
public function testGetDestinationPlugin() {
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration(['destination' => ['no_stub' => TRUE]]);
$this->setExpectedException(MigrateSkipRowException::class, "Stub requested but not made because no_stub configuration is set.");
$migration->getDestinationPlugin(TRUE);
}
}
@@ -51,7 +51,7 @@ class DownloadTest extends FileTestBase {
$destination_uri = $this->createUri('another_existing_file.txt');
// Test non-destructive download.
$actual_destination = $this->doTransform($destination_uri, ['rename' => TRUE]);
$actual_destination = $this->doTransform($destination_uri, ['file_exists' => 'rename']);
$this->assertSame('public://another_existing_file_0.txt', $actual_destination, 'Import returned a renamed destination');
$this->assertFileExists($actual_destination, 'Downloaded file was created');
}
@@ -9,6 +9,7 @@ use Drupal\migrate\Plugin\migrate\process\FileCopy;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\migrate\Row;
use GuzzleHttp\Client;
/**
* Tests the file_copy process plugin.
@@ -50,17 +51,17 @@ class FileCopyTest extends FileTestBase {
// Test a local to local copy.
[
$this->root . '/core/modules/simpletest/files/image-test.jpg',
'public://file1.jpg'
'public://file1.jpg',
],
// Test a temporary file using an absolute path.
[
$file_absolute,
'temporary://test.jpg'
'temporary://test.jpg',
],
// Test a temporary file using a relative path.
[
$file_absolute,
'temporary://core/modules/simpletest/files/test.jpg'
'temporary://core/modules/simpletest/files/test.jpg',
],
];
foreach ($data_sets as $data) {
@@ -76,30 +77,52 @@ class FileCopyTest extends FileTestBase {
/**
* Test successful file reuse.
*
* @dataProvider providerSuccessfulReuse
*
* @param string $source_path
* Source path to copy from.
* @param string $destination_path
* The destination path to copy to.
*/
public function testSuccessfulReuse() {
$source_path = $this->root . '/core/modules/simpletest/files/image-test.jpg';
$destination_path = 'public://file1.jpg';
$file_reuse = file_unmanaged_copy($source_path, $destination_path);
public function testSuccessfulReuse($source_path, $destination_path) {
$file_reuse = $this->doTransform($source_path, $destination_path);
clearstatcache(TRUE, $destination_path);
$timestamp = (new \SplFileInfo($file_reuse))->getMTime();
$this->assertInternalType('int', $timestamp);
// We need to make sure the modified timestamp on the file is sooner than
// the attempted migration.
sleep(1);
$configuration = ['reuse' => TRUE];
$configuration = ['file_exists' => 'use existing'];
$this->doTransform($source_path, $destination_path, $configuration);
clearstatcache(TRUE, $destination_path);
$modified_timestamp = (new \SplFileInfo($destination_path))->getMTime();
$this->assertEquals($timestamp, $modified_timestamp);
$configuration = ['reuse' => FALSE];
$this->doTransform($source_path, $destination_path, $configuration);
$this->doTransform($source_path, $destination_path);
clearstatcache(TRUE, $destination_path);
$modified_timestamp = (new \SplFileInfo($destination_path))->getMTime();
$this->assertGreaterThan($timestamp, $modified_timestamp);
}
/**
* Provides the source and destination path files.
*/
public function providerSuccessfulReuse() {
return [
[
'local_source_path' => static::getDrupalRoot() . '/core/modules/simpletest/files/image-test.jpg',
'local_destination_path' => 'public://file1.jpg',
],
[
'remote_source_path' => 'https://www.drupal.org/favicon.ico',
'remote_destination_path' => 'public://file2.jpg',
],
];
}
/**
* Test successful moves.
*/
@@ -113,17 +136,17 @@ class FileCopyTest extends FileTestBase {
// Test a local to local copy.
[
$local_file,
'public://file1.jpg'
'public://file1.jpg',
],
// Test a temporary file using an absolute path.
[
$file_1_absolute,
'temporary://test.jpg'
'temporary://test.jpg',
],
// Test a temporary file using a relative path.
[
$file_2_absolute,
'temporary://core/modules/simpletest/files/test.jpg'
'temporary://core/modules/simpletest/files/test.jpg',
],
];
foreach ($data_sets as $data) {
@@ -179,7 +202,7 @@ class FileCopyTest extends FileTestBase {
$source = $this->createUri(NULL, NULL, 'temporary');
$destination = $this->createUri('foo.txt', NULL, 'public');
$expected_destination = 'public://foo_0.txt';
$actual_destination = $this->doTransform($source, $destination, ['rename' => TRUE]);
$actual_destination = $this->doTransform($source, $destination, ['file_exists' => 'rename']);
$this->assertFileExists($expected_destination, 'File was renamed on import');
$this->assertSame($actual_destination, $expected_destination, 'The importer returned the renamed filename.');
}
@@ -222,6 +245,9 @@ class FileCopyTest extends FileTestBase {
* The URI of the copied file.
*/
protected function doTransform($source_path, $destination_path, $configuration = []) {
// Prepare a mock HTTP client.
$this->container->set('http_client', $this->createMock(Client::class));
$plugin = FileCopy::create($this->container, $configuration, 'file_copy', []);
$executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
$row = new Row([], []);
@@ -95,9 +95,9 @@ class MigrateExecutableTest extends MigrateTestCase {
->will($this->returnValue(['id' => 'test']));
$this->idMap->expects($this->once())
->method('lookupDestinationId')
->method('lookupDestinationIds')
->with(['id' => 'test'])
->will($this->returnValue(['test']));
->will($this->returnValue([['test']]));
$source->expects($this->once())
->method('current')
@@ -137,9 +137,9 @@ class MigrateExecutableTest extends MigrateTestCase {
->will($this->returnValue(['id' => 'test']));
$this->idMap->expects($this->once())
->method('lookupDestinationId')
->method('lookupDestinationIds')
->with(['id' => 'test'])
->will($this->returnValue(['test']));
->will($this->returnValue([['test']]));
$source->expects($this->once())
->method('current')
@@ -213,9 +213,9 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('saveMessage');
$this->idMap->expects($this->once())
->method('lookupDestinationId')
->method('lookupDestinationIds')
->with(['id' => 'test'])
->will($this->returnValue(['test']));
->will($this->returnValue([['test']]));
$this->message->expects($this->once())
->method('display')
@@ -269,9 +269,9 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('saveMessage');
$this->idMap->expects($this->once())
->method('lookupDestinationId')
->method('lookupDestinationIds')
->with(['id' => 'test'])
->will($this->returnValue(['test']));
->will($this->returnValue([['test']]));
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
}
@@ -319,7 +319,7 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('saveMessage');
$this->idMap->expects($this->never())
->method('lookupDestinationId');
->method('lookupDestinationIds');
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
}
@@ -367,9 +367,9 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('saveMessage');
$this->idMap->expects($this->once())
->method('lookupDestinationId')
->method('lookupDestinationIds')
->with(['id' => 'test'])
->will($this->returnValue(['test']));
->will($this->returnValue([['test']]));
$this->message->expects($this->once())
->method('display')
@@ -384,7 +384,7 @@ class MigrateExecutableTest extends MigrateTestCase {
public function testProcessRow() {
$expected = [
'test' => 'test destination',
'test1' => 'test1 destination'
'test1' => 'test1 destination',
];
foreach ($expected as $key => $value) {
$plugins[$key][0] = $this->getMock('Drupal\migrate\Plugin\MigrateProcessInterface');
@@ -28,7 +28,7 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
'type' => 'varchar',
'length' => 64,
'not null' => 1,
'description' => 'Hash of source ids. Used as primary key'
'description' => 'Hash of source ids. Used as primary key',
];
$fields['sourceid1'] = [
'type' => 'int',
@@ -101,7 +101,7 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
'type' => 'varchar',
'length' => 64,
'not null' => 1,
'description' => 'Hash of source ids. Used as primary key'
'description' => 'Hash of source ids. Used as primary key',
];
$fields['level'] = [
'type' => 'int',
@@ -166,7 +166,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$expected_result = [
[
'sourceid1' => 'source_value',
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash($source),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash($source),
'destid1' => 2,
] + $this->idMapDefaults(),
];
@@ -178,7 +178,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$id_map->saveIdMapping($row, ['destination_id_property' => 3]);
$expected_result[] = [
'sourceid1' => 'source_value_1',
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash($source),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash($source),
'destid1' => 3,
] + $this->idMapDefaults();
$this->queryResultTest($this->getIdMapContents(), $expected_result);
@@ -236,7 +236,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$id_map->saveIdMapping($row, $destination, $status);
$expected_results[] = [
'sourceid1' => 'source_value_' . $status,
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash($source),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash($source),
'destid1' => 'destination_value_' . $status,
'source_row_status' => $status,
'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
@@ -348,14 +348,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$row = [
'sourceid1' => 'source_id_value_1',
'sourceid2' => 'source_id_value_2',
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash(['source_id_property' => 'source_id_value_1']),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash(['source_id_property' => 'source_id_value_1']),
'destid1' => 'destination_id_value_1',
] + $this->idMapDefaults();
$this->saveMap($row);
$row = [
'sourceid1' => 'source_id_value_3',
'sourceid2' => 'source_id_value_4',
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash(['source_id_property' => 'source_id_value_3', 'sourceid2' => 'source_id_value_4']),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash(['source_id_property' => 'source_id_value_3', 'sourceid2' => 'source_id_value_4']),
'destid1' => 'destination_id_value_2',
] + $this->idMapDefaults();
$this->saveMap($row);
@@ -419,7 +419,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$expected_result[] = "destination_id_value_$i";
$this->destinationIds["destination_id_property_$i"] = [];
}
$row['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash($source_id_values);
$row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash($source_id_values);
$this->saveMap($row);
$id_map = $this->getIdMap();
// Test for a valid hit.
@@ -458,7 +458,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
foreach ($rows as $row) {
$values = array_combine($db_keys, $row);
$source_values = array_slice($row, 0, count($source_keys));
$values['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash($source_values);
$values['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash($source_values);
$this->saveMap($values);
}
@@ -517,6 +517,8 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$this->assertEquals([[101, 'en'], [101, 'fr'], [101, 'de']], $id_map->lookupDestinationIds(['nid' => 1]));
$this->assertEquals([[102, 'en']], $id_map->lookupDestinationIds(['nid' => 2]));
$this->assertEquals([], $id_map->lookupDestinationIds(['nid' => 99]));
$this->assertEquals([[101, 'en'], [101, 'fr'], [101, 'de']], $id_map->lookupDestinationIds(['nid' => 1, 'language' => NULL]));
$this->assertEquals([[102, 'en']], $id_map->lookupDestinationIds(['nid' => 2, 'language' => NULL]));
// Out-of-order partial associative list.
$this->assertEquals([[101, 'en'], [102, 'en']], $id_map->lookupDestinationIds(['language' => 'en']));
$this->assertEquals([[101, 'fr']], $id_map->lookupDestinationIds(['language' => 'fr']));
@@ -527,14 +529,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$this->fail('Too many source IDs should throw');
}
catch (MigrateException $e) {
$this->assertEquals("Extra unknown items in source IDs", $e->getMessage());
$this->assertEquals("Extra unknown items in source IDs: array (\n 0 => 3,\n)", $e->getMessage());
}
try {
$id_map->lookupDestinationIds(['nid' => 1, 'aaa' => '2']);
$this->fail('Unknown source ID key should throw');
}
catch (MigrateException $e) {
$this->assertEquals("Extra unknown items in source IDs", $e->getMessage());
$this->assertEquals("Extra unknown items in source IDs: array (\n 'aaa' => '2',\n)", $e->getMessage());
}
// Verify that we are looking up by source_id_hash when all source IDs are
@@ -554,14 +556,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$row = [
'sourceid1' => 'source_id_value_1',
'sourceid2' => 'source_id_value_2',
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash(['source_id_property' => 'source_id_value_1']),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash(['source_id_property' => 'source_id_value_1']),
'destid1' => 'destination_id_value_1',
] + $this->idMapDefaults();
$this->saveMap($row);
$row = [
'sourceid1' => 'source_id_value_3',
'sourceid2' => 'source_id_value_4',
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash(['source_id_property' => 'source_id_value_3']),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash(['source_id_property' => 'source_id_value_3']),
'destid1' => 'destination_id_value_2',
] + $this->idMapDefaults();
$this->saveMap($row);
@@ -577,7 +579,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
}
/**
* Data provider for testLookupSourceIDMapping().
* Data provider for testLookupSourceIdMapping().
*
* Scenarios to test (for both hits and misses) are:
* - Single-value destination ID to single-value source ID.
@@ -588,7 +590,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
* @return array
* An array of data values.
*/
public function lookupSourceIDMappingDataProvider() {
public function lookupSourceIdMappingDataProvider() {
return [
[1, 1],
[2, 2],
@@ -605,9 +607,9 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
* @param int $num_destination_fields
* Number of destination fields to test.
*
* @dataProvider lookupSourceIDMappingDataProvider
* @dataProvider lookupSourceIdMappingDataProvider
*/
public function testLookupSourceIDMapping($num_source_fields, $num_destination_fields) {
public function testLookupSourceIdMapping($num_source_fields, $num_destination_fields) {
// Adjust the migration configuration according to the number of source and
// destination fields.
$this->sourceIds = [];
@@ -629,14 +631,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$nonexistent_id_values["destination_id_property_$i"] = "nonexistent_destination_id_value_$i";
$this->destinationIds["destination_id_property_$i"] = [];
}
$row['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash($source_ids_values);
$row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash($source_ids_values);
$this->saveMap($row);
$id_map = $this->getIdMap();
// Test for a valid hit.
$source_id = $id_map->lookupSourceID($destination_id_values);
$source_id = $id_map->lookupSourceId($destination_id_values);
$this->assertSame($expected_result, $source_id);
// Test for a miss.
$source_id = $id_map->lookupSourceID($nonexistent_id_values);
$source_id = $id_map->lookupSourceId($nonexistent_id_values);
$this->assertSame(0, count($source_id));
}
@@ -765,7 +767,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
for ($i = 0; $i < 5; $i++) {
$row = $this->idMapDefaults();
$row['sourceid1'] = "source_id_value_$i";
$row['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash(['source_id_property' => $row['sourceid1']]);
$row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash(['source_id_property' => $row['sourceid1']]);
$row['destid1'] = "destination_id_value_$i";
$row['source_row_status'] = MigrateIdMapInterface::STATUS_IMPORTED;
$this->saveMap($row);
@@ -773,7 +775,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
for (; $i < 5 + $num_update_rows; $i++) {
$row = $this->idMapDefaults();
$row['sourceid1'] = "source_id_value_$i";
$row['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash(['source_id_property' => $row['sourceid1']]);
$row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash(['source_id_property' => $row['sourceid1']]);
$row['destid1'] = "destination_id_value_$i";
$row['source_row_status'] = MigrateIdMapInterface::STATUS_NEEDS_UPDATE;
$this->saveMap($row);
@@ -813,7 +815,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
for ($i = 0; $i < 5; $i++) {
$row = $this->idMapDefaults();
$row['sourceid1'] = "source_id_value_$i";
$row['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash(['source_id_property' => $row['sourceid1']]);
$row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash(['source_id_property' => $row['sourceid1']]);
$row['destid1'] = "destination_id_value_$i";
$row['source_row_status'] = MigrateIdMapInterface::STATUS_IMPORTED;
$this->saveMap($row);
@@ -821,7 +823,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
for (; $i < 5 + $num_error_rows; $i++) {
$row = $this->idMapDefaults();
$row['sourceid1'] = "source_id_value_$i";
$row['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash(['source_id_property' => $row['sourceid1']]);
$row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash(['source_id_property' => $row['sourceid1']]);
$row['destid1'] = "destination_id_value_$i";
$row['source_row_status'] = MigrateIdMapInterface::STATUS_FAILED;
$this->saveMap($row);
@@ -849,7 +851,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$id_map->saveIdMapping($row, $destination, $status);
$expected_results[] = [
'sourceid1' => 'source_value_' . $status,
'source_ids_hash' => $this->getIdMap()->getSourceIDsHash($source),
'source_ids_hash' => $this->getIdMap()->getSourceIdsHash($source),
'destid1' => 'destination_value_' . $status,
'source_row_status' => $status,
'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
@@ -978,7 +980,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
for ($i = 0; $i < 3; $i++) {
$row = $this->idMapDefaults();
$row['sourceid1'] = "source_id_value_$i";
$row['source_ids_hash'] = $this->getIdMap()->getSourceIDsHash(['source_id_property' => $row['sourceid1']]);
$row['source_ids_hash'] = $this->getIdMap()->getSourceIdsHash(['source_id_property' => $row['sourceid1']]);
$row['destid1'] = "destination_id_value_$i";
$row['source_row_status'] = MigrateIdMapInterface::STATUS_IMPORTED;
$expected_results[serialize(['sourceid1' => $row['sourceid1']])] = ['destid1' => $row['destid1']];
@@ -1010,4 +1012,27 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
return $contents;
}
/**
* Tests the delayed creation of the "map" and "message" migrate tables.
*/
public function testMapTableCreation() {
$id_map = $this->getIdMap();
$map_table_name = $id_map->mapTableName();
$message_table_name = $id_map->messageTableName();
// Check that tables names do exist.
$this->assertEquals('migrate_map_sql_idmap_test', $map_table_name);
$this->assertEquals('migrate_message_sql_idmap_test', $message_table_name);
// Check that tables don't exist.
$this->assertFalse($this->database->schema()->tableExists($map_table_name));
$this->assertFalse($this->database->schema()->tableExists($message_table_name));
$id_map->getDatabase();
// Check that tables do exist.
$this->assertTrue($this->database->schema()->tableExists($map_table_name));
$this->assertTrue($this->database->schema()->tableExists($message_table_name));
}
}
@@ -19,7 +19,7 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
/**
* The tested source plugin.
*
* @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase.
* @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
*/
protected $source;
@@ -29,7 +29,7 @@ abstract class MigrateTestCase extends UnitTestCase {
/**
* Local store for mocking setStatus()/getStatus().
*
* @var \Drupal\migrate\Plugin\MigrationInterface::STATUS_*
* @var int
*/
protected $migrationStatus = MigrationInterface::STATUS_IDLE;
@@ -8,17 +8,11 @@
namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Row;
use Drupal\Tests\UnitTestCase;
/**
* Tests base entity migration destination functionality.
@@ -26,43 +20,7 @@ use Drupal\Tests\UnitTestCase;
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\destination\EntityContentBase
* @group migrate
*/
class EntityContentBaseTest extends UnitTestCase {
/**
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* @var \Drupal\Core\Entity\EntityTypeInterface
*/
protected $entityType;
/**
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migration = $this->prophesize(MigrationInterface::class);
$this->storage = $this->prophesize(EntityStorageInterface::class);
$this->entityType = $this->prophesize(EntityTypeInterface::class);
$this->entityType->getPluralLabel()->willReturn('wonkiness');
$this->storage->getEntityType()->willReturn($this->entityType->reveal());
$this->entityManager = $this->prophesize(EntityManagerInterface::class);
}
class EntityContentBaseTest extends EntityTestBase {
/**
* Test basic entity save.
@@ -129,7 +87,7 @@ class EntityContentBaseTest extends UnitTestCase {
$this->entityManager->reveal(),
$this->prophesize(FieldTypePluginManagerInterface::class)->reveal()
);
$this->setExpectedException(MigrateException::class, 'This entity type does not support translation');
$this->setExpectedException(MigrateException::class, 'The "foo" entity type does not support translations.');
$destination->getIds();
}
@@ -157,22 +115,3 @@ class EntityTestDestination extends EntityContentBase {
}
}
/**
* Stub class for BaseFieldDefinition.
*/
class BaseFieldDefinitionTest extends BaseFieldDefinition {
public static function create($type) {
return new static([]);
}
public function getSettings() {
return [];
}
public function getType() {
return 'integer';
}
}
@@ -0,0 +1,113 @@
<?php
namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\migrate\destination\EntityRevision;
use Drupal\migrate\Row;
/**
* Tests entity revision destination functionality.
*
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\destination\EntityRevision
* @group migrate
*/
class EntityRevisionTest extends EntityTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migration = $this->prophesize(MigrationInterface::class);
$this->storage = $this->prophesize(EntityStorageInterface::class);
$this->entityType = $this->prophesize(EntityTypeInterface::class);
$this->entityType->getSingularLabel()->willReturn('foo');
$this->entityType->getPluralLabel()->willReturn('bar');
$this->storage->getEntityType()->willReturn($this->entityType->reveal());
$this->storage->getEntityTypeId()->willReturn('foo');
$this->entityManager = $this->prophesize(EntityManagerInterface::class);
}
/**
* Tests that revision destination fails for unrevisionable entities.
*/
public function testUnrevisionable() {
$this->entityType->getKey('id')->willReturn('id');
$this->entityType->getKey('revision')->willReturn('');
$this->entityManager->getBaseFieldDefinitions('foo')
->willReturn([
'id' => BaseFieldDefinitionTest::create('integer'),
]);
$destination = new EntityRevisionTestDestination(
[],
'',
[],
$this->migration->reveal(),
$this->storage->reveal(),
[],
$this->entityManager->reveal(),
$this->prophesize(FieldTypePluginManagerInterface::class)->reveal()
);
$this->setExpectedException(MigrateException::class, 'The "foo" entity type does not support revisions.');
$destination->getIds();
}
/**
* Tests that translation destination fails for untranslatable entities.
*/
public function testUntranslatable() {
$this->entityType->getKey('id')->willReturn('id');
$this->entityType->getKey('revision')->willReturn('vid');
$this->entityType->getKey('langcode')->willReturn('');
$this->entityManager->getBaseFieldDefinitions('foo')
->willReturn([
'id' => BaseFieldDefinitionTest::create('integer'),
'vid' => BaseFieldDefinitionTest::create('integer'),
]);
$destination = new EntityRevisionTestDestination(
['translations' => TRUE],
'',
[],
$this->migration->reveal(),
$this->storage->reveal(),
[],
$this->entityManager->reveal(),
$this->prophesize(FieldTypePluginManagerInterface::class)->reveal()
);
$this->setExpectedException(MigrateException::class, 'The "foo" entity type does not support translations.');
$destination->getIds();
}
}
/**
* Stub class for testing EntityRevision methods.
*/
class EntityRevisionTestDestination extends EntityRevision {
private $entity = NULL;
public function setEntity($entity) {
$this->entity = $entity;
}
protected function getEntity(Row $row, array $old_destination_id_values) {
return $this->entity;
}
public static function getEntityTypeId($plugin_id) {
return 'foo';
}
}
@@ -0,0 +1,78 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityTestBase
*/
namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\Tests\UnitTestCase;
/**
* Base test class forentity migration destination functionality.
*/
class EntityTestBase extends UnitTestCase {
/**
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* @var \Drupal\Core\Entity\EntityTypeInterface
*/
protected $entityType;
/**
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->migration = $this->prophesize(MigrationInterface::class);
$this->storage = $this->prophesize(EntityStorageInterface::class);
$this->entityType = $this->prophesize(EntityTypeInterface::class);
$this->entityType->getPluralLabel()->willReturn('wonkiness');
$this->storage->getEntityType()->willReturn($this->entityType->reveal());
$this->storage->getEntityTypeId()->willReturn('foo');
$this->entityManager = $this->prophesize(EntityManagerInterface::class);
}
}
/**
* Stub class for BaseFieldDefinition.
*/
class BaseFieldDefinitionTest extends BaseFieldDefinition {
public static function create($type) {
return new static([]);
}
public function getSettings() {
return [];
}
public function getType() {
return 'integer';
}
}
@@ -176,7 +176,6 @@ class EntityRevisionTest extends UnitTestCase {
$this->assertEquals([1234], $destination->save($entity->reveal(), []));
}
/**
* Helper method to create an entity revision destination with mock services.
*
@@ -230,6 +229,8 @@ class EntityRevision extends RealEntityRevision {
* workings of its implementation which would trickle into mock assertions. An
* empty implementation avoids this.
*/
protected function updateEntity(EntityInterface $entity, Row $row) {}
protected function updateEntity(EntityInterface $entity, Row $row) {
return $entity;
}
}
@@ -53,13 +53,16 @@ class PerComponentEntityDisplayTest extends MigrateTestCase {
class TestPerComponentEntityDisplay extends ComponentEntityDisplayBase {
const MODE_NAME = 'view_mode';
protected $testValues;
public function __construct($entity) {
$this->entity = $entity;
}
protected function getEntity($entity_type, $bundle, $view_mode) {
$this->testValues = func_get_args();
return $this->entity;
}
public function getTestValues() {
return $this->testValues;
}
@@ -53,13 +53,16 @@ class PerComponentEntityFormDisplayTest extends MigrateTestCase {
class TestPerComponentEntityFormDisplay extends PerComponentEntityFormDisplay {
const MODE_NAME = 'form_mode';
protected $testValues;
public function __construct($entity) {
$this->entity = $entity;
}
protected function getEntity($entity_type, $bundle, $form_mode) {
$this->testValues = func_get_args();
return $this->entity;
}
public function getTestValues() {
return $this->testValues;
}
@@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate\Unit\process\CallbackTest.
*/
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\migrate\Plugin\migrate\process\Callback;
@@ -17,39 +12,66 @@ use Drupal\migrate\Plugin\migrate\process\Callback;
class CallbackTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
* Test callback with valid "callable".
*
* @dataProvider providerCallback
*/
protected function setUp() {
$this->plugin = new TestCallback();
parent::setUp();
}
/**
* Test callback with a function as callable.
*/
public function testCallbackWithFunction() {
$this->plugin->setCallable('strtolower');
public function testCallback($callable) {
$configuration = ['callable' => $callable];
$this->plugin = new Callback($configuration, 'map', []);
$value = $this->plugin->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame('foobar', $value);
}
/**
* Test callback with a class method as callable.
* Data provider for ::testCallback().
*/
public function testCallbackWithClassMethod() {
$this->plugin->setCallable(['\Drupal\Component\Utility\Unicode', 'strtolower']);
$value = $this->plugin->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame('foobar', $value);
}
}
class TestCallback extends Callback {
public function __construct() {
}
public function setCallable($callable) {
$this->configuration['callable'] = $callable;
public function providerCallback() {
return [
'function' => ['strtolower'],
'class method' => [[self::class, 'strtolower']],
];
}
/**
* Test callback excpetions.
*
* @dataProvider providerCallbackExceptions
*/
public function testCallbackExceptions($message, $configuration) {
$this->setExpectedException(\InvalidArgumentException::class, $message);
$this->plugin = new Callback($configuration, 'map', []);
}
/**
* Data provider for ::testCallbackExceptions().
*/
public function providerCallbackExceptions() {
return [
'not set' => [
'message' => 'The "callable" must be set.',
'configuration' => [],
],
'invalid method' => [
'message' => 'The "callable" must be a valid function or method.',
'configuration' => ['callable' => 'nonexistent_callable'],
],
];
}
/**
* Makes a string lowercase for testing purposes.
*
* @param string $string
* The input string.
*
* @return string
* The lowercased string.
*
* @see \Drupal\Tests\migrate\Unit\process\CallbackTest::providerCallback()
*/
public static function strToLower($string) {
return mb_strtolower($string);
}
}
@@ -53,6 +53,7 @@ class ConcatTest extends MigrateProcessTestCase {
}
class TestConcat extends Concat {
public function __construct() {
}
@@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\migrate\Plugin\migrate\process\DedupeEntity;
use Drupal\Component\Utility\Unicode;
/**
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\DedupeEntity
@@ -18,7 +17,7 @@ class DedupeEntityTest extends MigrateProcessTestCase {
/**
* The mock entity query.
*
* @var \Drupal\Core\Entity\Query\QueryInterface|\Drupal\Core\Entity\Query\QueryFactory
* @var \Drupal\Core\Entity\Query\QueryInterface
*/
protected $entityQuery;
@@ -77,7 +76,7 @@ class DedupeEntityTest extends MigrateProcessTestCase {
$this->entityQueryExpects($count);
$value = $this->randomMachineName(32);
$actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'testproperty');
$expected = Unicode::substr($value, $start, $length);
$expected = mb_substr($value, $start, $length);
$expected .= $count ? $postfix . $count : '';
$this->assertSame($expected, $actual);
}
@@ -198,7 +197,7 @@ class DedupeEntityTest extends MigrateProcessTestCase {
// Entity 'forums' is pre-existing, entity 'test_vocab' was migrated.
$this->idMap
->method('lookupSourceID')
->method('lookupSourceId')
->will($this->returnValueMap([
[['test_field' => 'forums'], FALSE],
[['test_field' => 'test_vocab'], ['source_id' => 42]],
@@ -0,0 +1,149 @@
<?php
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Drupal\migrate\Plugin\migrate\process\FileCopy;
use Drupal\migrate\Plugin\MigrateProcessInterface;
/**
* Flag for dealing with existing files: Appends number until name is unique.
*/
define('FILE_EXISTS_RENAME', 0);
/**
* Flag for dealing with existing files: Replace the existing file.
*/
define('FILE_EXISTS_REPLACE', 1);
/**
* Flag for dealing with existing files: Do nothing and return FALSE.
*/
define('FILE_EXISTS_ERROR', 2);
/**
* Tests the file copy process plugin.
*
* @group migrate
* @group legacy
*
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\FileCopy
*/
class FileCopyTest extends MigrateProcessTestCase {
/**
* Tests that the rename configuration key will trigger a deprecation notice.
*
* @dataProvider providerDeprecationNoticeRename
*
* @param array $configuration
* The plugin configuration.
* @param $expected
* The expected value of the plugin configuration.
*
* @expectedDeprecation Using the key 'rename' is deprecated, use 'file_exists' => 'rename' instead. See https://www.drupal.org/node/2981389.
*/
public function testDeprecationNoticeRename($configuration, $expected) {
$this->assertPlugin($configuration, $expected);
}
/**
* Data provider for testDeprecationNoticeRename.
*/
public function providerDeprecationNoticeRename() {
return [
[['rename' => TRUE], FILE_EXISTS_RENAME],
[['rename' => FALSE], FILE_EXISTS_REPLACE],
];
}
/**
* Tests that the reuse configuration key will trigger a deprecation notice.
*
* @dataProvider providerDeprecationNoticeReuse
*
* @param array $configuration
* The plugin configuration.
* @param $expected
* The expected value of the plugin configuration.
*
* @expectedDeprecation Using the key 'reuse' is deprecated, use 'file_exists' => 'use existing' instead. See https://www.drupal.org/node/2981389.
*/
public function testDeprecationNoticeReuse($configuration, $expected) {
$this->assertPlugin($configuration, $expected);
}
/**
* Data provider for testDeprecationNoticeReuse.
*/
public function providerDeprecationNoticeReuse() {
return [
[['reuse' => TRUE], FILE_EXISTS_ERROR],
[['reuse' => FALSE], FILE_EXISTS_REPLACE],
];
}
/**
* Tests that the plugin constructor correctly sets the configuration.
*
* @dataProvider providerFileProcessBaseConstructor
*
* @param array $configuration
* The plugin configuration.
* @param $expected
* The expected value of the plugin configuration.
*/
public function testFileProcessBaseConstructor($configuration, $expected) {
$this->assertPlugin($configuration, $expected);
}
/**
* Data provider for testFileProcessBaseConstructor.
*/
public function providerFileProcessBaseConstructor() {
return [
[['file_exists' => 'replace'], FILE_EXISTS_REPLACE],
[['file_exists' => 'rename'], FILE_EXISTS_RENAME],
[['file_exists' => 'use existing'], FILE_EXISTS_ERROR],
[['file_exists' => 'foobar'], FILE_EXISTS_REPLACE],
[[], FILE_EXISTS_REPLACE],
];
}
/**
* Creates a TestFileCopy process plugin.
*
* @param array $configuration
* The plugin configuration.
* @param $expected
* The expected value of the plugin configuration.
*/
protected function assertPlugin($configuration, $expected) {
$stream_wrapper_manager = $this->prophesize(StreamWrapperManagerInterface::class)->reveal();
$file_system = $this->prophesize(FileSystemInterface::class)->reveal();
$download_plugin = $this->prophesize(MigrateProcessInterface::class)->reveal();
$this->plugin = new TestFileCopy($configuration, 'test', [], $stream_wrapper_manager, $file_system, $download_plugin);
$plugin_config = $this->plugin->getConfiguration();
$this->assertArrayHasKey('file_exists', $plugin_config);
$this->assertSame($expected, $plugin_config['file_exists']);
}
}
/**
* Class for testing FileCopy.
*/
class TestFileCopy extends FileCopy {
/**
* Gets this plugin's configuration.
*
* @return array
* An array of this plugin's configuration.
*/
public function getConfiguration() {
return $this->configuration;
}
}
@@ -85,7 +85,7 @@ class FormatDateTest extends MigrateProcessTestCase {
'timezone' => 'America/Managua',
],
'value' => '2004-12-19T10:19:42-0600',
'expected' => '2004-12-19T10:19:42-06:00 -06:00'
'expected' => '2004-12-19T10:19:42-06:00 -06:00',
],
];
}
@@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate\Unit\process\GetTest.
*/
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\migrate\Plugin\migrate\process\TestGet;
use Drupal\migrate\Plugin\migrate\process\Get;
/**
* Tests the get process plugin.
@@ -16,14 +11,6 @@ use Drupal\migrate\Plugin\migrate\process\TestGet;
*/
class GetTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->plugin = new TestGet();
parent::setUp();
}
/**
* Tests the Get plugin when source is a string.
*/
@@ -32,7 +19,7 @@ class GetTest extends MigrateProcessTestCase {
->method('getSourceProperty')
->with('test')
->will($this->returnValue('source_value'));
$this->plugin->setSource('test');
$this->plugin = new Get(['source' => 'test'], '', []);
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame('source_value', $value);
}
@@ -45,7 +32,7 @@ class GetTest extends MigrateProcessTestCase {
'test1' => 'source_value1',
'test2' => 'source_value2',
];
$this->plugin->setSource(['test1', 'test2']);
$this->plugin = new Get(['source' => ['test1', 'test2']], '', []);
$this->row->expects($this->exactly(2))
->method('getSourceProperty')
->will($this->returnCallback(function ($argument) use ($map) {
@@ -63,7 +50,7 @@ class GetTest extends MigrateProcessTestCase {
->method('getSourceProperty')
->with('@test')
->will($this->returnValue('source_value'));
$this->plugin->setSource('@@test');
$this->plugin = new Get(['source' => '@@test'], '', []);
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame('source_value', $value);
}
@@ -78,7 +65,7 @@ class GetTest extends MigrateProcessTestCase {
'@test3' => 'source_value3',
'test4' => 'source_value4',
];
$this->plugin->setSource(['test1', '@@test2', '@@test3', 'test4']);
$this->plugin = new Get(['source' => ['test1', '@@test2', '@@test3', 'test4']], '', []);
$this->row->expects($this->exactly(4))
->method('getSourceProperty')
->will($this->returnCallback(function ($argument) use ($map) {
@@ -90,34 +77,47 @@ class GetTest extends MigrateProcessTestCase {
/**
* Tests the Get plugin when source has integer values.
*
* @dataProvider integerValuesDataProvider
*/
public function testIntegerValues() {
$this->row->expects($this->exactly(2))
public function testIntegerValues($source, $expected_value) {
$this->row->expects($this->atMost(2))
->method('getSourceProperty')
->willReturnOnConsecutiveCalls('val1', 'val2');
$this->plugin->setSource([0 => 0, 1 => 'test']);
$this->plugin = new Get(['source' => $source], '', []);
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame([0 => 'val1', 1 => 'val2'], $return);
$this->assertSame($expected_value, $return);
}
$this->plugin->setSource([FALSE]);
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame([NULL], $return);
/**
* Provides data for the successful lookup test.
*
* @return array
*/
public function integerValuesDataProvider() {
return [
[
'source' => [0 => 0, 1 => 'test'],
'expected_value' => [0 => 'val1', 1 => 'val2'],
],
[
'source' => [FALSE],
'expected_value' => [NULL],
],
[
'source' => [NULL],
'expected_value' => [NULL],
],
];
}
$this->plugin->setSource([NULL]);
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame([NULL], $return);
}
}
namespace Drupal\migrate\Plugin\migrate\process;
class TestGet extends Get {
public function __construct() {
}
public function setSource($source) {
$this->configuration['source'] = $source;
/**
* Tests the Get plugin for syntax errors, e.g. "Invalid tag_line detected" by
* creating a prophecy of the class.
*/
public function testPluginSyntax() {
$this->assertNotNull($this->prophesize(Get::class));
}
}
@@ -18,7 +18,7 @@ class IteratorTest extends MigrateTestCase {
/**
* The iterator plugin being tested.
*
* @var \Drupal\migrate\Plugin\migrate\process\TestIterator
* @var \Drupal\migrate\Plugin\migrate\process\Iterator
*/
protected $plugin;
@@ -33,6 +33,7 @@ class IteratorTest extends MigrateTestCase {
* Tests the iterator process plugin.
*
* @group legacy
* @expectedDeprecation The Drupal\migrate\Plugin\migrate\process\Iterator is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate\Plugin\migrate\process\SubProcess
*/
public function testIterator() {
$migration = $this->getMigration();
@@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\migrate\Plugin\migrate\process\MakeUniqueEntityField;
use Drupal\Component\Utility\Unicode;
/**
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\MakeUniqueEntityField
@@ -17,7 +16,7 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase {
/**
* The mock entity query.
*
* @var \Drupal\Core\Entity\Query\QueryInterface|\Drupal\Core\Entity\Query\QueryFactory
* @var \Drupal\Core\Entity\Query\QueryInterface
*/
protected $entityQuery;
@@ -76,7 +75,7 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase {
$this->entityQueryExpects($count);
$value = $this->randomMachineName(32);
$actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'testproperty');
$expected = Unicode::substr($value, $start, $length);
$expected = mb_substr($value, $start, $length);
$expected .= $count ? $postfix . $count : '';
$this->assertSame($expected, $actual);
}
@@ -197,7 +196,7 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase {
// Entity 'forums' is pre-existing, entity 'test_vocab' was migrated.
$this->idMap
->method('lookupSourceID')
->method('lookupSourceId')
->will($this->returnValueMap([
[['test_field' => 'forums'], FALSE],
[['test_field' => 'test_vocab'], ['source_id' => 42]],
@@ -0,0 +1,38 @@
<?php
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Menu\MenuLinkManagerInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\migrate\process\MenuLinkParent;
use Drupal\migrate\Plugin\MigrateProcessInterface;
/**
* Tests the menu link parent process plugin.
*
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\MenuLinkParent
* @group migrate
*/
class MenuLinkParentTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$migration_plugin = $this->prophesize(MigrateProcessInterface::class);
$menu_link_manager = $this->prophesize(MenuLinkManagerInterface::class);
$menu_link_storage = $this->prophesize(EntityStorageInterface::class);
$this->plugin = new MenuLinkParent([], 'map', [], $migration_plugin->reveal(), $menu_link_manager->reveal(), $menu_link_storage->reveal());
}
/**
* @covers ::transform
*/
public function testTransformException() {
$this->setExpectedException(MigrateSkipRowException::class, "No parent link found for plid '1' in menu 'admin'.");
$this->plugin->transform([1, 'admin', NULL], $this->migrateExecutable, $this->row, 'destinationproperty');
}
}
@@ -4,6 +4,7 @@ namespace Drupal\Tests\migrate\Unit\process;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\migrate\MigrateSkipProcessException;
use Drupal\migrate\Plugin\migrate\process\Get;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\migrate\process\MigrationLookup;
use Drupal\migrate\Plugin\MigrateDestinationInterface;
@@ -249,7 +250,7 @@ class MigrationLookupTest extends MigrateProcessTestCase {
$migration_plugin_manager = $this->prophesize(MigrationPluginManagerInterface::class);
$process_plugin_manager = $this->prophesize(MigratePluginManager::class);
$foobaz_migration = $this->prophesize(MigrationInterface::class);
$get_migration = $this->prophesize(MigrationLookup::class);
$get_migration = $this->prophesize(Get::class);
$id_map = $this->prophesize(MigrateIdMapInterface::class);
$destination_plugin = $this->prophesize(MigrateDestinationInterface::class);
$source_plugin = $this->prophesize(MigrateSourceInterface::class);
@@ -2,6 +2,7 @@
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\Component\Utility\Variable;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\migrate\process\StaticMap;
@@ -50,7 +51,7 @@ class StaticMapTest extends MigrateProcessTestCase {
* Tests when the source is invalid.
*/
public function testMapwithInvalidSource() {
$this->setExpectedException(MigrateSkipRowException::class);
$this->setExpectedException(MigrateSkipRowException::class, sprintf("No static mapping found for '%s' and no default value provided for destination '%s'.", Variable::export(['bar']), 'destinationproperty'));
$this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
}