MigrationConfigEntityTest.php in Migrate Plus 8.2
File
tests/src/Kernel/MigrationConfigEntityTest.php
View source
<?php
namespace Drupal\Tests\migrate_plus\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate_plus\Entity\Migration;
use Drupal\migrate_plus\Plugin\MigrationConfigEntityPluginManager;
class MigrationConfigEntityTest extends KernelTestBase {
public static $modules = [
'migrate',
'migrate_plus',
];
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']);
$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']);
}
}