Skip to content
Snippets Groups Projects
Commit 6cfbb3e9 authored by Lucas Hedding's avatar Lucas Hedding Committed by Lucas Hedding
Browse files

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

parent cbb509db
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,8 @@ use Drupal\Core\Entity\EntityTypeInterface; ...@@ -18,7 +18,8 @@ use Drupal\Core\Entity\EntityTypeInterface;
* entity_keys = { * entity_keys = {
* "id" = "id", * "id" = "id",
* "label" = "label", * "label" = "label",
* "weight" = "weight" * "weight" = "weight",
* "status" = "status"
* } * }
* ) * )
*/ */
......
...@@ -20,6 +20,10 @@ class MigrationConfigDeriver extends DeriverBase { ...@@ -20,6 +20,10 @@ class MigrationConfigDeriver extends DeriverBase {
$migrations = Migration::loadMultiple(); $migrations = Migration::loadMultiple();
/** @var \Drupal\migrate_plus\Entity\MigrationInterface $migration */ /** @var \Drupal\migrate_plus\Entity\MigrationInterface $migration */
foreach ($migrations as $id => $migration) { foreach ($migrations as $id => $migration) {
if (!$migration->status()) {
continue;
}
$this->derivatives[$id] = $migration->toArray(); $this->derivatives[$id] = $migration->toArray();
} }
return $this->derivatives; return $this->derivatives;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Tests\migrate_plus\Kernel; namespace Drupal\Tests\migrate_plus\Kernel;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate_plus\Entity\Migration; use Drupal\migrate_plus\Entity\Migration;
...@@ -35,6 +36,7 @@ class MigrationConfigEntityTest extends KernelTestBase { ...@@ -35,6 +36,7 @@ class MigrationConfigEntityTest extends KernelTestBase {
public function testCacheInvalidation() { public function testCacheInvalidation() {
$config = Migration::create([ $config = Migration::create([
'id' => 'test', 'id' => 'test',
'status' => TRUE,
'label' => 'Label A', 'label' => 'Label A',
'migration_tags' => [], 'migration_tags' => [],
'source' => [], 'source' => [],
...@@ -57,4 +59,41 @@ class MigrationConfigEntityTest extends KernelTestBase { ...@@ -57,4 +59,41 @@ class MigrationConfigEntityTest extends KernelTestBase {
$this->assertSame('Label B', $this->pluginManager->getDefinition('test')['label']); $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');
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment