public function KeyValueEntityStorageTest::testSaveContentEntity in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest::testSaveContentEntity()
@covers ::save @covers ::doSave
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php, line 413 - Contains \Drupal\Tests\Core\Entity\KeyValueStore\KeyValueEntityStorageTest.
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(array(
'id' => 'id',
)));
$this
->setUpKeyValueEntityStorage();
$expected = array(
'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', array(), array(
'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);
}