function KeyValueEntityStorageTest::testSaveDuplicate
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveDuplicate()
- 10 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveDuplicate()
- 11.x core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveDuplicate()
@covers ::save @covers ::doSave
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php, line 442
Class
- KeyValueEntityStorageTest
- @coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage @group Entity
Namespace
Drupal\Tests\Core\Entity\KeyValueStoreCode
public function testSaveDuplicate() {
$this->setUpKeyValueEntityStorage();
$entity = $this->getMockEntity('Drupal\\Core\\Entity\\EntityBase', [
[
'id' => 'foo',
],
]);
$entity->enforceIsNew();
$this->keyValueStore
->expects($this->once())
->method('has')
->willReturn(TRUE);
$this->keyValueStore
->expects($this->never())
->method('set');
$this->keyValueStore
->expects($this->never())
->method('delete');
$this->expectException(EntityStorageException::class);
$this->expectExceptionMessage("'test_entity_type' entity with ID 'foo' already exists");
$this->entityStorage
->save($entity);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.