386363a36593458cfb445bd56f1fbaab4b7b9da5
[yaffs-website] / web / modules / contrib / migrate_plus / tests / src / Kernel / MigrationConfigEntityTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate_plus\Kernel;
4
5 use Drupal\KernelTests\KernelTestBase;
6 use Drupal\migrate_plus\Entity\Migration;
7
8 /**
9  * Test migration config entity discovery.
10  *
11  * @group migrate_plus
12  */
13 class MigrationConfigEntityTest extends KernelTestBase {
14
15   public static $modules = ['migrate', 'migrate_plus'];
16
17   /**
18    * @var \Drupal\migrate\Plugin\MigrationPluginManager
19    */
20   protected $pluginManager;
21
22   protected function setUp() {
23     parent::setUp();
24     $this->pluginManager = \Drupal::service('plugin.manager.migration');
25   }
26
27   public function testCacheInvalidation() {
28     $config = Migration::create([
29       'id' => 'test',
30       'label' => 'Label A',
31       'migration_tags' => [],
32       'source' => [],
33       'destination' => [],
34       'migration_dependencies' => [],
35     ]);
36     $config->save();
37
38     $this->assertTrue($this->pluginManager->getDefinition('test'));
39     $this->assertSame('Label A', $this->pluginManager->getDefinition('test')['label']);
40
41     // Clear static cache in the plugin manager, the cache tag take care of the
42     // persistent cache.
43     $this->pluginManager->useCaches(FALSE);
44     $this->pluginManager->useCaches(TRUE);
45
46     $config->set('label', 'Label B');
47     $config->save();
48
49     $this->assertSame('Label B', $this->pluginManager->getDefinition('test')['label']);
50   }
51
52 }