class TestMigrateExecutable

Same name in this branch
  1. 8.9.x core/modules/migrate/tests/src/Kernel/TestMigrateExecutable.php \Drupal\Tests\migrate\Kernel\TestMigrateExecutable
Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php \Drupal\Tests\migrate\Unit\TestMigrateExecutable
  2. 9 core/modules/migrate/tests/src/Kernel/TestMigrateExecutable.php \Drupal\Tests\migrate\Kernel\TestMigrateExecutable
  3. 9 core/modules/migrate/tests/src/Kernel/Plugin/LogTest.php \Drupal\Tests\migrate\Kernel\Plugin\TestMigrateExecutable
  4. 10 core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php \Drupal\Tests\migrate\Unit\TestMigrateExecutable
  5. 10 core/modules/migrate/tests/src/Kernel/TestMigrateExecutable.php \Drupal\Tests\migrate\Kernel\TestMigrateExecutable
  6. 10 core/modules/migrate/tests/src/Kernel/Plugin/LogTest.php \Drupal\Tests\migrate\Kernel\Plugin\TestMigrateExecutable
  7. 11.x core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php \Drupal\Tests\migrate\Unit\TestMigrateExecutable
  8. 11.x core/modules/migrate/tests/src/Kernel/TestMigrateExecutable.php \Drupal\Tests\migrate\Kernel\TestMigrateExecutable
  9. 11.x core/modules/migrate/tests/src/Kernel/Plugin/LogTest.php \Drupal\Tests\migrate\Kernel\Plugin\TestMigrateExecutable

Tests MigrateExecutable.

Hierarchy

Expanded class hierarchy of TestMigrateExecutable

File

core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php, line 11

Namespace

Drupal\Tests\migrate\Unit
View source
class TestMigrateExecutable extends MigrateExecutable {
    
    /**
     * The fake memory usage in bytes.
     *
     * @var int
     */
    protected $memoryUsage;
    
    /**
     * The cleared memory usage.
     *
     * @var int
     */
    protected $clearedMemoryUsage;
    
    /**
     * Sets the string translation service.
     *
     * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
     *   The translation manager.
     */
    public function setStringTranslation(TranslationInterface $string_translation) {
        $this->stringTranslation = $string_translation;
    }
    
    /**
     * Allows access to set protected source property.
     *
     * @param \Drupal\migrate\Plugin\MigrateSourceInterface $source
     *   The value to set.
     */
    public function setSource($source) {
        $this->source = $source;
    }
    
    /**
     * Allows access to protected sourceIdValues property.
     *
     * @param array $source_id_values
     *   The values to set.
     */
    public function setSourceIdValues($source_id_values) {
        $this->sourceIdValues = $source_id_values;
    }
    
    /**
     * {@inheritdoc}
     */
    public function handleException(\Exception $exception, $save = TRUE) {
        $message = $exception->getMessage();
        if ($save) {
            $this->saveMessage($message);
        }
        $this->message
            ->display($message);
    }
    
    /**
     * Allows access to the protected memoryExceeded method.
     *
     * @return bool
     *   The memoryExceeded value.
     */
    public function memoryExceeded() {
        return parent::memoryExceeded();
    }
    
    /**
     * {@inheritdoc}
     */
    protected function attemptMemoryReclaim() {
        return $this->clearedMemoryUsage;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getMemoryUsage() {
        return $this->memoryUsage;
    }
    
    /**
     * Sets the fake memory usage.
     *
     * @param int $memory_usage
     *   The fake memory usage value.
     * @param int $cleared_memory_usage
     *   (optional) The fake cleared memory value. Defaults to NULL.
     */
    public function setMemoryUsage($memory_usage, $cleared_memory_usage = NULL) {
        $this->memoryUsage = $memory_usage;
        $this->clearedMemoryUsage = $cleared_memory_usage;
    }
    
    /**
     * Sets the memory limit.
     *
     * @param int $memory_limit
     *   The memory limit.
     */
    public function setMemoryLimit($memory_limit) {
        $this->memoryLimit = $memory_limit;
    }
    
    /**
     * Sets the memory threshold.
     *
     * @param float $threshold
     *   The new threshold.
     */
    public function setMemoryThreshold($threshold) {
        $this->memoryThreshold = $threshold;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function formatSize($size) {
        return $size;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
MigrateExecutable::$counts protected property An array of counts. Initially used for cache hit/miss tracking.
MigrateExecutable::$eventDispatcher protected property The event dispatcher.
MigrateExecutable::$memoryLimit protected property The PHP memory_limit expressed in bytes.
MigrateExecutable::$memoryThreshold protected property The ratio of the memory limit at which an operation will be interrupted.
MigrateExecutable::$message public property Migration message service.
MigrateExecutable::$migration protected property The configuration of the migration to do.
MigrateExecutable::$source protected property The source.
MigrateExecutable::$sourceIdValues protected property The configuration values of the source.
MigrateExecutable::$sourceRowStatus protected property Status of one row.
MigrateExecutable::checkStatus protected function Checks for exceptional conditions, and display feedback.
MigrateExecutable::currentSourceIds protected function Fetches the key array for the current source record.
MigrateExecutable::getEventDispatcher protected function Gets the event dispatcher.
MigrateExecutable::getIdMap protected function Get the ID map from the current migration. 1
MigrateExecutable::getSource protected function Returns the source. 1
MigrateExecutable::import public function Performs an import operation - migrate items from source to destination. Overrides MigrateExecutableInterface::import
MigrateExecutable::processRow public function Processes a row. Overrides MigrateExecutableInterface::processRow
MigrateExecutable::rollback public function Performs a rollback operation - remove previously-imported items. Overrides MigrateExecutableInterface::rollback
MigrateExecutable::saveMessage public function Passes messages through to the map class. Overrides MigrateExecutableInterface::saveMessage
MigrateExecutable::__construct public function Constructs a MigrateExecutable and verifies and sets the memory limit.
StringTranslationTrait::$stringTranslation protected property The string translation service.
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::t protected function Translates a string to the current language or to a given language.
TestMigrateExecutable::$clearedMemoryUsage protected property The cleared memory usage.
TestMigrateExecutable::$memoryUsage protected property The fake memory usage in bytes.
TestMigrateExecutable::attemptMemoryReclaim protected function Tries to reclaim memory. Overrides MigrateExecutable::attemptMemoryReclaim
TestMigrateExecutable::formatSize protected function Generates a string representation for the given byte count. Overrides MigrateExecutable::formatSize
TestMigrateExecutable::getMemoryUsage protected function Returns the memory usage so far. Overrides MigrateExecutable::getMemoryUsage
TestMigrateExecutable::handleException public function Takes an Exception object and both saves and displays it. Overrides MigrateExecutable::handleException
TestMigrateExecutable::memoryExceeded public function Allows access to the protected memoryExceeded method. Overrides MigrateExecutable::memoryExceeded
TestMigrateExecutable::setMemoryLimit public function Sets the memory limit.
TestMigrateExecutable::setMemoryThreshold public function Sets the memory threshold.
TestMigrateExecutable::setMemoryUsage public function Sets the fake memory usage.
TestMigrateExecutable::setSource public function Allows access to set protected source property.
TestMigrateExecutable::setSourceIdValues public function Allows access to protected sourceIdValues property.
TestMigrateExecutable::setStringTranslation public function Sets the string translation service. Overrides StringTranslationTrait::setStringTranslation

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.