function ConfigEntityStorageTest::testSaveUpdate
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveUpdate()
- 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveUpdate()
- 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveUpdate()
@covers ::save @covers ::doSave
@depends testSaveInsert
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to test.
Return value
\Drupal\Core\Entity\EntityInterface
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityStorageTest.php, line 309
Class
- ConfigEntityStorageTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testSaveUpdate(EntityInterface $entity) {
$immutable_config_object = $this->prophesize(ImmutableConfig::class);
$immutable_config_object->isNew()
->willReturn(FALSE);
$config_object = $this->prophesize(Config::class);
$config_object->setData([
'id' => 'foo',
'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
->loadMultiple([
'the_provider.the_config_prefix.foo',
])
->willReturn([])
->shouldBeCalledTimes(2);
$this->configFactory
->get('the_provider.the_config_prefix.foo')
->willReturn($immutable_config_object->reveal())
->shouldBeCalledTimes(1);
$this->configFactory
->getEditable('the_provider.the_config_prefix.foo')
->willReturn($config_object->reveal())
->shouldBeCalledTimes(1);
$this->moduleHandler
->invokeAll('test_entity_type_presave', [
$entity,
])
->shouldBeCalled();
$this->moduleHandler
->invokeAll('entity_presave', [
$entity,
'test_entity_type',
])
->shouldBeCalled();
$this->moduleHandler
->invokeAll('test_entity_type_update', [
$entity,
])
->shouldBeCalled();
$this->moduleHandler
->invokeAll('entity_update', [
$entity,
'test_entity_type',
])
->shouldBeCalled();
$this->entityQuery
->condition('uuid', 'bar')
->willReturn($this->entityQuery);
$this->entityQuery
->execute()
->willReturn([
$entity->id(),
]);
$return = $this->entityStorage
->save($entity);
$this->assertSame(SAVED_UPDATED, $return);
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.