Commit 634dfcee authored by webchick's avatar webchick

Issue #2560659 by benjy, phenaproxima, neclimdul: Invalidate the Migration...

Issue #2560659 by benjy, phenaproxima, neclimdul: Invalidate the Migration destination plugin when overriding with set()
parent 39902b80
......@@ -480,6 +480,10 @@ public function set($property_name, $value) {
// Invalidate the source plugin.
unset($this->sourcePlugin);
}
elseif ($property_name === 'destination') {
// Invalidate the destination plugin.
unset($this->destinationPlugin);
}
return parent::set($property_name, $value);
}
......
<?php
namespace Drupal\migrate\Tests;
use Drupal\migrate\Entity\Migration;
use Drupal\simpletest\KernelTestBase;
/**
* Tests the migration entity.
*
* @group migrate
* @coversDefaultClass \Drupal\migrate\Entity\Migration
*/
class MigrationTest extends KernelTestBase {
/**
* Enable field because we're using one of its source plugins.
*
* @var array
*/
public static $modules = ['migrate', 'field'];
/**
* Tests Migration::set()
*
* @covers ::set()
*/
public function testSetInvalidation() {
$migration = Migration::create([
'source' => ['plugin' => 'empty'],
'destination' => ['plugin' => 'entity:entity_view_mode'],
]);
$this->assertEqual('empty', $migration->getSourcePlugin()->getPluginId());
$this->assertEqual('entity:entity_view_mode', $migration->getDestinationPlugin()->getPluginId());
// Test the source plugin is invalidated.
$migration->set('source', ['plugin' => 'd6_field']);
$this->assertEqual('d6_field', $migration->getSourcePlugin()->getPluginId());
// Test the destination plugin is invalidated.
$migration->set('destination', ['plugin' => 'null']);
$this->assertEqual('null', $migration->getDestinationPlugin()->getPluginId());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment