function ConfigEntityBaseUnitTest::testPreSaveDuringSync
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testPreSaveDuringSync()
- 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testPreSaveDuringSync()
- 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testPreSaveDuringSync()
@covers ::preSave
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityBaseUnitTest.php, line 189
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testPreSaveDuringSync() : void {
$this->moduleHandler
->moduleExists('node')
->willReturn(TRUE);
$query = $this->createMock('\\Drupal\\Core\\Entity\\Query\\QueryInterface');
$storage = $this->createMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
$query->expects($this->any())
->method('execute')
->willReturn([]);
$query->expects($this->any())
->method('condition')
->willReturn($query);
$storage->expects($this->any())
->method('getQuery')
->willReturn($query);
$storage->expects($this->any())
->method('loadUnchanged')
->willReturn($this->entity);
// Saving an entity will not reset the dependencies array during config
// synchronization.
$this->entity
->set('dependencies', [
'module' => [
'node',
],
]);
$this->entity
->preSave($storage);
$this->assertEmpty($this->entity
->getDependencies());
$this->entity
->setSyncing(TRUE);
$this->entity
->set('dependencies', [
'module' => [
'node',
],
]);
$this->entity
->preSave($storage);
$dependencies = $this->entity
->getDependencies();
$this->assertContains('node', $dependencies['module']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.