public function KeyValueEntityStorageTest::testSaveUpdate 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::testSaveUpdate()
@covers ::save @covers ::doSave
@depends testSaveInsert
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
Return value
\Drupal\Core\Entity\EntityInterface
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ KeyValueStore/ KeyValueEntityStorageTest.php, line 279 - 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 testSaveUpdate(EntityInterface $entity) {
$this->entityType
->expects($this
->once())
->method('getClass')
->will($this
->returnValue(get_class($entity)));
$this
->setUpKeyValueEntityStorage();
$expected = array(
'id' => 'foo',
);
$this->keyValueStore
->expects($this
->exactly(2))
->method('has')
->with('foo')
->will($this
->returnValue(TRUE));
$this->keyValueStore
->expects($this
->once())
->method('getMultiple')
->with(array(
'foo',
))
->will($this
->returnValue(array(
array(
'id' => 'foo',
),
)));
$this->keyValueStore
->expects($this
->never())
->method('delete');
$this->moduleHandler
->expects($this
->at(0))
->method('getImplementations')
->with('entity_load')
->will($this
->returnValue(array()));
$this->moduleHandler
->expects($this
->at(1))
->method('getImplementations')
->with('test_entity_type_load')
->will($this
->returnValue(array()));
$this->moduleHandler
->expects($this
->at(2))
->method('invokeAll')
->with('test_entity_type_presave');
$this->moduleHandler
->expects($this
->at(3))
->method('invokeAll')
->with('entity_presave');
$this->moduleHandler
->expects($this
->at(4))
->method('invokeAll')
->with('test_entity_type_update');
$this->moduleHandler
->expects($this
->at(5))
->method('invokeAll')
->with('entity_update');
$this->keyValueStore
->expects($this
->once())
->method('set')
->with('foo', $expected);
$return = $this->entityStorage
->save($entity);
$this
->assertSame(SAVED_UPDATED, $return);
return $entity;
}