public function ConfigEntityStorageTest::testSaveUpdate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::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/ Config/ Entity/ ConfigEntityStorageTest.php, line 351 - Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest.
Class
- ConfigEntityStorageTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testSaveUpdate(EntityInterface $entity) {
$config_object = $this
->getMockBuilder('Drupal\\Core\\Config\\Config')
->disableOriginalConstructor()
->getMock();
$config_object
->expects($this
->atLeastOnce())
->method('isNew')
->will($this
->returnValue(FALSE));
$config_object
->expects($this
->exactly(1))
->method('setData');
$config_object
->expects($this
->once())
->method('save');
$config_object
->expects($this
->atLeastOnce())
->method('get')
->willReturn([]);
$this->cacheTagsInvalidator
->expects($this
->once())
->method('invalidateTags')
->with(array(
// List cache tag only; the own cache tag is invalidated by the config
// system.
$this->entityTypeId . '_list',
));
$this->configFactory
->expects($this
->exactly(2))
->method('loadMultiple')
->with(array(
'the_config_prefix.foo',
))
->will($this
->returnValue(array()));
$this->configFactory
->expects($this
->exactly(1))
->method('get')
->with('the_config_prefix.foo')
->will($this
->returnValue($config_object));
$this->configFactory
->expects($this
->exactly(1))
->method('getEditable')
->with('the_config_prefix.foo')
->will($this
->returnValue($config_object));
$this->moduleHandler
->expects($this
->at(0))
->method('invokeAll')
->with('test_entity_type_presave');
$this->moduleHandler
->expects($this
->at(1))
->method('invokeAll')
->with('entity_presave');
$this->moduleHandler
->expects($this
->at(2))
->method('invokeAll')
->with('test_entity_type_update');
$this->moduleHandler
->expects($this
->at(3))
->method('invokeAll')
->with('entity_update');
$this->entityQuery
->expects($this
->once())
->method('condition')
->with('uuid', 'bar')
->will($this
->returnSelf());
$this->entityQuery
->expects($this
->once())
->method('execute')
->will($this
->returnValue(array(
$entity
->id(),
)));
$return = $this->entityStorage
->save($entity);
$this
->assertSame(SAVED_UPDATED, $return);
return $entity;
}