Mercurial > hg > cmmr2012-drupal-site
annotate 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 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\migrate_plus\Tests; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Component\Plugin\Exception\PluginNotFoundException; |
Chris@0 | 6 use Drupal\KernelTests\KernelTestBase; |
Chris@0 | 7 use Drupal\migrate_plus\Entity\Migration; |
Chris@0 | 8 use Drupal\migrate_plus\Plugin\MigrationConfigEntityPluginManager; |
Chris@0 | 9 |
Chris@0 | 10 /** |
Chris@0 | 11 * Test migration config entity discovery. |
Chris@0 | 12 * |
Chris@0 | 13 * @group migrate_plus |
Chris@0 | 14 */ |
Chris@0 | 15 class MigrationConfigEntityTest extends KernelTestBase { |
Chris@0 | 16 |
Chris@0 | 17 public static $modules = ['migrate', 'migrate_plus']; |
Chris@0 | 18 |
Chris@0 | 19 /** |
Chris@0 | 20 * @var MigrationConfigEntityPluginManager |
Chris@0 | 21 */ |
Chris@0 | 22 protected $pluginMananger; |
Chris@0 | 23 |
Chris@0 | 24 protected function setUp() { |
Chris@0 | 25 parent::setUp(); |
Chris@0 | 26 $this->pluginMananger = \Drupal::service('plugin.manager.config_entity_migration'); |
Chris@0 | 27 } |
Chris@0 | 28 |
Chris@0 | 29 public function testCacheInvalidation() { |
Chris@0 | 30 $config = Migration::create([ |
Chris@0 | 31 'id' => 'test', |
Chris@0 | 32 'label' => 'Label A', |
Chris@0 | 33 'migration_tags' => [], |
Chris@0 | 34 'source' => [], |
Chris@0 | 35 'destination' => [], |
Chris@0 | 36 'migration_dependencies' => [], |
Chris@0 | 37 ]); |
Chris@0 | 38 $config->save(); |
Chris@0 | 39 |
Chris@0 | 40 $this->assertTrue($this->pluginMananger->getDefinition('test')); |
Chris@0 | 41 $this->assertSame('Label A', $this->pluginMananger->getDefinition('test')['label']); |
Chris@0 | 42 |
Chris@0 | 43 // Clear static cache in the plugin manager, the cache tag take care of the |
Chris@0 | 44 // persistent cache. |
Chris@0 | 45 $this->pluginMananger->useCaches(FALSE); |
Chris@0 | 46 $this->pluginMananger->useCaches(TRUE); |
Chris@0 | 47 |
Chris@0 | 48 $config->set('label', 'Label B'); |
Chris@0 | 49 $config->save(); |
Chris@0 | 50 |
Chris@0 | 51 $this->assertSame('Label B', $this->pluginMananger->getDefinition('test')['label']); |
Chris@0 | 52 $this->assertSame('Label B', \Drupal::service('plugin.manager.migration')->getDefinition('test')['label']); |
Chris@0 | 53 } |
Chris@0 | 54 |
Chris@0 | 55 } |