You are here

class TestSmartSqlIdMap in Smart SQL ID Map 1.1.x

Same name and namespace in other branches
  1. 1.0.x tests/src/Unit/TestSmartSqlIdMap.php \Drupal\Tests\smart_sql_idmap\Unit\TestSmartSqlIdMap

A Smart SQL ID map-based plugin that can be used for testing SmartSql.

Hierarchy

Expanded class hierarchy of TestSmartSqlIdMap

1 file declares its use of TestSmartSqlIdMap
SmartSqlTest.php in tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php

File

tests/src/Unit/TestSmartSqlIdMap.php, line 15

Namespace

Drupal\Tests\smart_sql_idmap\Unit
View source
class TestSmartSqlIdMap extends SmartSql implements \Iterator {

  /**
   * The migration plugin manager.
   *
   * @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
   */
  protected $migrationPluginManager;

  /**
   * Constructs a TestSqlIdMap object.
   *
   * @param \Drupal\Core\Database\Connection $database
   *   The database.
   * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
   *   The migration plugin manager.
   * @param array $configuration
   *   The configuration.
   * @param string $plugin_id
   *   The plugin ID for the migration process to do.
   * @param mixed $plugin_definition
   *   The configuration for the plugin.
   * @param \Drupal\migrate\Plugin\MigrationInterface $migration
   *   The migration to do.
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
   *   The event dispatcher service.
   */
  public function __construct(Connection $database, MigrationPluginManagerInterface $migration_plugin_manager, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) {
    $this->database = $database;
    $this->migrationPluginManager = $migration_plugin_manager;
    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher);
  }

  /**
   * {@inheritdoc}
   */
  public $message;

  /**
   * {@inheritdoc}
   */
  protected function getMigrationPluginManager() {
    return $this->migrationPluginManager;
  }

  /**
   * Gets the field schema.
   *
   * @param array $id_definition
   *   An array defining the field, with a key 'type'.
   *
   * @return array
   *   A field schema depending on value of key 'type'.  An empty array is
   *   returned if 'type' is not defined.
   *
   * @throws \Drupal\migrate\MigrateException
   */
  protected function getFieldSchema(array $id_definition) {
    if (!isset($id_definition['type'])) {
      return [];
    }
    switch ($id_definition['type']) {
      case 'integer':
        return [
          'type' => 'int',
          'not null' => TRUE,
        ];
      case 'string':
        return [
          'type' => 'varchar',
          'length' => 255,
          'not null' => FALSE,
        ];
      default:
        throw new MigrateException($id_definition['type'] . ' not supported');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
MigrateIdMapInterface::ROLLBACK_DELETE constant Indicates that the data for the row is to be deleted.
MigrateIdMapInterface::ROLLBACK_PRESERVE constant Indicates that the data for the row is to be preserved.
MigrateIdMapInterface::STATUS_FAILED constant Indicates that the import of the row failed.
MigrateIdMapInterface::STATUS_IGNORED constant Indicates that the import of the row was ignored.
MigrateIdMapInterface::STATUS_IMPORTED constant Indicates that the import of the row was successful.
MigrateIdMapInterface::STATUS_NEEDS_UPDATE constant Indicates that the row needs to be updated.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
SmartSql::getRowByDestination public function Overrides Sql::getRowByDestination
Sql::$currentKey protected property The current key.
Sql::$currentRow protected property The current row.
Sql::$database protected property The database connection for the map/message tables on the destination.
Sql::$destinationIdFields protected property The destination ID fields.
Sql::$destinationIds protected property The destination identifiers.
Sql::$eventDispatcher protected property An event dispatcher instance to use for map events.
Sql::$initialized protected property Whether the plugin is already initialized.
Sql::$mapTableName protected property The migration map table name.
Sql::$messageTableName protected property The message table name.
Sql::$migration protected property The migration being done.
Sql::$query protected property The select query.
Sql::$result protected property The result.
Sql::$sourceIdFields protected property The source ID fields.
Sql::$sourceIds protected property The source identifiers.
Sql::clearMessages public function Clears all messages from the map. Overrides MigrateIdMapInterface::clearMessages
Sql::countHelper protected function Counts records in a table.
Sql::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
Sql::current public function Implementation of \Iterator::current().
Sql::currentDestination public function Looks up the destination identifier currently being iterated. Overrides MigrateIdMapInterface::currentDestination
Sql::currentSource public function Looks up the source identifier(s) currently being iterated. Overrides MigrateIdMapInterface::currentSource
Sql::delete public function Deletes the map and message entries for a given source record. Overrides MigrateIdMapInterface::delete
Sql::deleteDestination public function Deletes the map and message table entries for a given destination row. Overrides MigrateIdMapInterface::deleteDestination
Sql::destinationIdFields protected function The destination ID fields.
Sql::destroy public function Removes any persistent storage used by this map. Overrides MigrateIdMapInterface::destroy
Sql::ensureTables protected function Create the map and message tables if they don't already exist. 1
Sql::errorCount public function Returns the number of items that failed to import. Overrides MigrateIdMapInterface::errorCount
Sql::getDatabase public function Gets the database connection. 1
Sql::getHighestId public function Returns the highest ID tracked by the implementing plugin. Overrides HighestIdInterface::getHighestId
Sql::getMessages public function Retrieves a traversable object of messages related to source records. Overrides MigrateIdMapInterface::getMessages
Sql::getQualifiedMapTableName public function Get the fully qualified map table name. Overrides MigrateIdMapInterface::getQualifiedMapTableName
Sql::getRowBySource public function Retrieves a row from the map table based on source identifier values. Overrides MigrateIdMapInterface::getRowBySource
Sql::getRowsNeedingUpdate public function Retrieves an array of map rows marked as needing update. Overrides MigrateIdMapInterface::getRowsNeedingUpdate
Sql::getSourceIdsHash public function Retrieves the hash of the source identifier values.
Sql::importedCount public function Returns the number of imported items in the map. Overrides MigrateIdMapInterface::importedCount
Sql::init protected function Initialize the plugin.
Sql::key public function Implementation of \Iterator::key().
Sql::lookupDestinationIds public function Looks up the destination identifiers corresponding to a source key. Overrides MigrateIdMapInterface::lookupDestinationIds
Sql::lookupSourceId public function Looks up the source identifier. Overrides MigrateIdMapInterface::lookupSourceId
Sql::mapTableName public function The name of the database map table.
Sql::messageCount public function Returns the number of messages saved. Overrides MigrateIdMapInterface::messageCount
Sql::messageTableName public function The name of the database message table.
Sql::next public function Implementation of \Iterator::next().
Sql::prepareUpdate public function Prepares to run a full update. Overrides MigrateIdMapInterface::prepareUpdate
Sql::processedCount public function Returns the number of processed items in the map. Overrides MigrateIdMapInterface::processedCount
Sql::rewind public function Implementation of \Iterator::rewind().
Sql::saveIdMapping public function Saves a mapping from the source identifiers to the destination identifiers. Overrides MigrateIdMapInterface::saveIdMapping
Sql::saveMessage public function Saves a message related to a source record in the migration message table. Overrides MigrateIdMapInterface::saveMessage
Sql::setMessage public function Sets the migrate message service. Overrides MigrateIdMapInterface::setMessage
Sql::setUpdate public function Sets a specified record to be updated, if it exists. Overrides MigrateIdMapInterface::setUpdate
Sql::sourceIdFields protected function The source ID fields.
Sql::SOURCE_IDS_HASH constant Column name of hashed source id values.
Sql::updateCount public function Returns a count of items which are marked as needing update. Overrides MigrateIdMapInterface::updateCount
Sql::valid public function Implementation of \Iterator::valid().
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TestSmartSqlIdMap::$message public property The migrate message service. Overrides Sql::$message
TestSmartSqlIdMap::$migrationPluginManager protected property The migration plugin manager.
TestSmartSqlIdMap::getFieldSchema protected function Gets the field schema. Overrides Sql::getFieldSchema
TestSmartSqlIdMap::getMigrationPluginManager protected function Returns the migration plugin manager. Overrides Sql::getMigrationPluginManager
TestSmartSqlIdMap::__construct public function Constructs a TestSqlIdMap object. Overrides SmartSql::__construct