public function KeyValueEntityStorageTest::testSaveContentEntity in Drupal 8
@covers ::save @covers ::doSave
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php, line 423
Class
- KeyValueEntityStorageTest
- @coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage @group Entity
Namespace
Drupal\Tests\Core\Entity\KeyValueStoreCode
public function testSaveContentEntity() {
$this->entityType
->expects($this
->any())
->method('getKeys')
->will($this
->returnValue([
'id' => 'id',
]));
$this
->setUpKeyValueEntityStorage();
$expected = [
'id' => 'foo',
];
$this->keyValueStore
->expects($this
->exactly(2))
->method('has')
->with('foo')
->will($this
->returnValue(FALSE));
$this->keyValueStore
->expects($this
->once())
->method('set')
->with('foo', $expected);
$this->keyValueStore
->expects($this
->never())
->method('delete');
$entity = $this
->getMockEntity('Drupal\\Core\\Entity\\ContentEntityBase', [], [
'toArray',
'id',
]);
$entity
->expects($this
->atLeastOnce())
->method('id')
->will($this
->returnValue('foo'));
$entity
->expects($this
->once())
->method('toArray')
->will($this
->returnValue($expected));
$this->entityStorage
->save($entity);
}