public function ConfigEntityStorageTest::testSaveInsert 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::testSaveInsert()
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::testSaveInsert()
@covers ::save @covers ::doSave
@depends testCreate
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 256
Class
- ConfigEntityStorageTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testSaveInsert(EntityInterface $entity) {
$immutable_config_object = $this
->prophesize(ImmutableConfig::class);
$immutable_config_object
->isNew()
->willReturn(TRUE);
$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
->get('the_provider.the_config_prefix.foo')
->willReturn($immutable_config_object
->reveal());
$this->configFactory
->getEditable('the_provider.the_config_prefix.foo')
->willReturn($config_object
->reveal());
$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_insert', [
$entity,
])
->shouldBeCalled();
$this->moduleHandler
->invokeAll('entity_insert', [
$entity,
'test_entity_type',
])
->shouldBeCalled();
$this->entityQuery
->condition('uuid', 'bar')
->willReturn($this->entityQuery);
$this->entityQuery
->execute()
->willReturn([]);
$return = $this->entityStorage
->save($entity);
$this
->assertSame(SAVED_NEW, $return);
return $entity;
}