You are here

public function MigrationConfigEntityTest::testCacheInvalidation in Migrate Plus 8.2

Same name and namespace in other branches
  1. 8.5 tests/src/Kernel/MigrationConfigEntityTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationConfigEntityTest::testCacheInvalidation()
  2. 8.3 tests/src/Kernel/MigrationConfigEntityTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationConfigEntityTest::testCacheInvalidation()
  3. 8.4 tests/src/Kernel/MigrationConfigEntityTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationConfigEntityTest::testCacheInvalidation()

File

tests/src/Kernel/MigrationConfigEntityTest.php, line 28

Class

MigrationConfigEntityTest
Test migration config entity discovery.

Namespace

Drupal\Tests\migrate_plus\Kernel

Code

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']);
}