/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create a mock migration. This will be injected into the source plugin // under test. $this->migration = $this->prophesize(MigrationInterface::class); $this->migration->id()->willReturn($this->randomMachineName(16)); // Prophesize a useless ID map plugin and an empty set of destination IDs. // Calling code can override these prophecies later and set up different // behaviors. $this->migration->getIdMap()->willReturn($this->prophesize(MigrateIdMapInterface::class)->reveal()); $this->migration->getDestinationIds()->willReturn([]); }
/** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->migration = $migration; // Set up some defaults based on the source configuration. $this->cacheCounts = !empty($configuration['cache_counts']); $this->skipCount = !empty($configuration['skip_count']); $this->cacheKey = !empty($configuration['cache_key']) ? !empty($configuration['cache_key']) : NULL; $this->trackChanges = !empty($configuration['track_changes']) ? $configuration['track_changes'] : FALSE; $this->idMap = $this->migration->getIdMap(); // Pull out the current highwater mark if we have a highwater property. if ($this->highWaterProperty = $this->migration->get('highWaterProperty')) { $this->originalHighWater = $this->migration->getHighWater(); } // Don't allow the use of both highwater and track changes together. if ($this->highWaterProperty && $this->trackChanges) { throw new MigrateException('You should either use a highwater mark or track changes not both. They are both designed to solve the same problem'); } }
/** * {@inheritdoc} */ public function saveMessage($message, $level = MigrationInterface::MESSAGE_ERROR) { $this->migration->getIdMap()->saveMessage($this->sourceIdValues, $message, $level); }