Commit 6cfbb3e9 authored by heddn's avatar heddn Committed by heddn

Issue #2987787 by SylvainM, heddn: Status of migration config file is not respected

parent cbb509db
......@@ -18,7 +18,8 @@ use Drupal\Core\Entity\EntityTypeInterface;
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "weight" = "weight"
* "weight" = "weight",
* "status" = "status"
* }
* )
*/
......
......@@ -20,6 +20,10 @@ class MigrationConfigDeriver extends DeriverBase {
$migrations = Migration::loadMultiple();
/** @var \Drupal\migrate_plus\Entity\MigrationInterface $migration */
foreach ($migrations as $id => $migration) {
if (!$migration->status()) {
continue;
}
$this->derivatives[$id] = $migration->toArray();
}
return $this->derivatives;
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\migrate_plus\Kernel;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate_plus\Entity\Migration;
......@@ -35,6 +36,7 @@ class MigrationConfigEntityTest extends KernelTestBase {
public function testCacheInvalidation() {
$config = Migration::create([
'id' => 'test',
'status' => TRUE,
'label' => 'Label A',
'migration_tags' => [],
'source' => [],
......@@ -57,4 +59,41 @@ class MigrationConfigEntityTest extends KernelTestBase {
$this->assertSame('Label B', $this->pluginManager->getDefinition('test')['label']);
}
/**
* Tests migration status.
*/
public function testMigrationStatus() {
$configs = [
[
'id' => 'test_active',
'status' => TRUE,
'label' => 'Label Active',
'migration_tags' => [],
'source' => [],
'destination' => [],
'migration_dependencies' => [],
],
[
'id' => 'test_inactive',
'status' => FALSE,
'label' => 'Label Inactive',
'migration_tags' => [],
'source' => [],
'destination' => [],
'migration_dependencies' => [],
],
];
foreach ($configs as $config) {
Migration::create($config)->save();
}
$definitions = $this->pluginManager->getDefinitions();
$this->assertCount(1, $definitions);
$this->assertArrayHasKey('test_active', $definitions);
$this->setExpectedException(PluginNotFoundException::class, 'The "test_inactive" plugin does not exist.');
$this->pluginManager->getDefinition('test_inactive');
}
}
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