354da7628af33b165db8bce8239e59661d942b14
[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    * The plugin manager.
19    *
20    * @var \Drupal\migrate\Plugin\MigrationPluginManager
21    */
22   protected $pluginManager;
23
24   /**
25    * {@inheritdoc}
26    */
27   protected function setUp() {
28     parent::setUp();
29     $this->pluginManager = \Drupal::service('plugin.manager.migration');
30   }
31
32   /**
33    * Tests cache invalidation.
34    */
35   public function testCacheInvalidation() {
36     $config = Migration::create([
37       'id' => 'test',
38       'label' => 'Label A',
39       'migration_tags' => [],
40       'source' => [],
41       'destination' => [],
42       'migration_dependencies' => [],
43     ]);
44     $config->save();
45
46     $this->assertTrue($this->pluginManager->getDefinition('test'));
47     $this->assertSame('Label A', $this->pluginManager->getDefinition('test')['label']);
48
49     // Clear static cache in the plugin manager, the cache tag take care of the
50     // persistent cache.
51     $this->pluginManager->useCaches(FALSE);
52     $this->pluginManager->useCaches(TRUE);
53
54     $config->set('label', 'Label B');
55     $config->save();
56
57     $this->assertSame('Label B', $this->pluginManager->getDefinition('test')['label']);
58   }
59
60 }