diff modules/contrib/migrate_plus/src/Tests/MigrationConfigEntityTest.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/contrib/migrate_plus/src/Tests/MigrationConfigEntityTest.php	Thu Jul 05 14:24:15 2018 +0000
@@ -0,0 +1,55 @@
+<?php
+
+namespace Drupal\migrate_plus\Tests;
+
+use Drupal\Component\Plugin\Exception\PluginNotFoundException;
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\migrate_plus\Entity\Migration;
+use Drupal\migrate_plus\Plugin\MigrationConfigEntityPluginManager;
+
+/**
+ * Test migration config entity discovery.
+ *
+ * @group migrate_plus
+ */
+class MigrationConfigEntityTest extends KernelTestBase {
+
+  public static $modules = ['migrate', 'migrate_plus'];
+
+  /**
+   * @var MigrationConfigEntityPluginManager
+   */
+  protected $pluginMananger;
+
+  protected function setUp() {
+    parent::setUp();
+    $this->pluginMananger = \Drupal::service('plugin.manager.config_entity_migration');
+  }
+
+  public function testCacheInvalidation() {
+    $config = Migration::create([
+      'id' => 'test',
+      'label' => 'Label A',
+      'migration_tags' => [],
+      'source' => [],
+      'destination' => [],
+      'migration_dependencies' => [],
+    ]);
+    $config->save();
+
+    $this->assertTrue($this->pluginMananger->getDefinition('test'));
+    $this->assertSame('Label A', $this->pluginMananger->getDefinition('test')['label']);
+
+    // Clear static cache in the plugin manager, the cache tag take care of the
+    // persistent cache.
+    $this->pluginMananger->useCaches(FALSE);
+    $this->pluginMananger->useCaches(TRUE);
+
+    $config->set('label', 'Label B');
+    $config->save();
+
+    $this->assertSame('Label B', $this->pluginMananger->getDefinition('test')['label']);
+    $this->assertSame('Label B', \Drupal::service('plugin.manager.migration')->getDefinition('test')['label']);
+  }
+
+}