function ConfigEntityBaseUnitTest::testSetWithPluginCollections
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testSetWithPluginCollections()
@covers ::set @dataProvider providerTestSetAndPreSaveWithPluginCollections
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityBaseUnitTest.php, line 651
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testSetWithPluginCollections(bool $syncing, string $expected_value) : void {
$instance_id = 'the_instance_id';
$instance = new TestConfigurablePlugin([
'foo' => 'original_value',
], $instance_id, []);
$plugin_manager = $this->prophesize(PluginManagerInterface::class);
if ($syncing) {
$plugin_manager->createInstance(Argument::cetera())
->shouldNotBeCalled();
}
else {
$plugin_manager->createInstance($instance_id, Argument::any())
->willReturn($instance);
}
$entity_values = [
'the_plugin_collection_config' => [
$instance_id => [
'id' => $instance_id,
'foo' => 'original_value',
],
],
];
$entity = new TestConfigEntityWithPluginCollections($entity_values, $this->entityTypeId);
$entity->setSyncing($syncing);
$entity->setPluginManager($plugin_manager->reveal());
// After creating the entity, change the configuration using the entity.
$entity->set('the_plugin_collection_config', [
$instance_id => [
'id' => $instance_id,
'foo' => 'new_value',
],
]);
$this->assertSame($expected_value, $instance->getConfiguration()['foo']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.