public function ConfigEntityStorageTest::testSaveRename in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveRename()
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveRename()
@covers ::save @covers ::doSave
@depends testSaveInsert
File
- core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityStorageTest.php, line 364
Class
- ConfigEntityStorageTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testSaveRename(ConfigEntityInterface $entity) {
$immutable_config_object = $this
->prophesize(ImmutableConfig::class);
$immutable_config_object
->isNew()
->willReturn(FALSE);
$config_object = $this
->prophesize(Config::class);
$config_object
->setData([
'id' => 'bar',
'uuid' => 'bar',
'dependencies' => [],
'langcode' => 'hu',
'status' => TRUE,
])
->shouldBeCalled();
$config_object
->save(FALSE)
->shouldBeCalled();
$config_object
->get()
->willReturn([]);
$this->cacheTagsInvalidator
->invalidateTags([
$this->entityTypeId . '_list',
])
->shouldBeCalled();
$this->configFactory
->get('the_provider.the_config_prefix.foo')
->willReturn($immutable_config_object
->reveal());
$this->configFactory
->loadMultiple([
'the_provider.the_config_prefix.foo',
])
->willReturn([]);
$this->configFactory
->rename('the_provider.the_config_prefix.foo', 'the_provider.the_config_prefix.bar')
->shouldBeCalled();
$this->configFactory
->getEditable('the_provider.the_config_prefix.bar')
->willReturn($config_object
->reveal());
// Performing a rename does not change the original ID until saving.
$this
->assertSame('foo', $entity
->getOriginalId());
$entity
->set('id', 'bar');
$this
->assertSame('foo', $entity
->getOriginalId());
$this->entityQuery
->condition('uuid', 'bar')
->willReturn($this->entityQuery);
$this->entityQuery
->execute()
->willReturn([
$entity
->id(),
]);
$return = $this->entityStorage
->save($entity);
$this
->assertSame(SAVED_UPDATED, $return);
$this
->assertSame('bar', $entity
->getOriginalId());
}