Skip to content
Snippets Groups Projects
Commit 5cd98e7b authored by Ivan Doroshenko's avatar Ivan Doroshenko
Browse files

Issue: #3269494: Add a test for config entity lookup.

parent 962e1ca0
No related branches found
No related tags found
2 merge requests!52Issue: #3269494: Add a test for config entity lookup.,!8Issue #3229479: Entity_lookup taxonomy_term restricted by VID
......@@ -21,6 +21,13 @@ final class EntityLookupTest extends KernelTestBase {
use UserCreationTrait;
/**
* The migrate executable mock object.
*
* @var \Drupal\migrate\MigrateExecutable|\PHPUnit\Framework\MockObject\MockObject
*/
protected $migrateExecutable;
/**
* {@inheritdoc}
*/
......@@ -29,6 +36,7 @@ final class EntityLookupTest extends KernelTestBase {
'migrate',
'user',
'system',
'filter',
];
/**
......@@ -38,6 +46,11 @@ final class EntityLookupTest extends KernelTestBase {
parent::setUp();
$this->installSchema('system', ['sequences']);
$this->installEntitySchema('user');
$this->installConfig(['filter']);
$this->migrateExecutable = $this->getMockBuilder('Drupal\migrate\MigrateExecutable')
->disableOriginalConstructor()
->getMock();
}
/**
......@@ -75,4 +88,29 @@ final class EntityLookupTest extends KernelTestBase {
$this->assertNull($value);
}
/**
* Tests a lookup of config entity.
*/
public function testConfigEntityLookup(): void {
$migration = \Drupal::service('plugin.manager.migration')
->createStubMigration([
'id' => 'test',
'source' => [],
'process' => [],
'destination' => [
'plugin' => 'entity:node',
],
]);
$configuration = [
'entity_type' => 'filter_format',
'value_key' => 'name',
];
$plugin = \Drupal::service('plugin.manager.migrate.process')
->createInstance('entity_lookup', $configuration, $migration);
$value = $plugin->transform('Plain text', $this->migrateExecutable, new Row(), 'destination_property');
$this->assertEquals('plain_text', $value);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment