public function ConfigEntityBaseUnitTest::testPreSaveDuringSync in Drupal 8
Same name and namespace in other branches
- 9 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 185 - Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest.
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testPreSaveDuringSync() {
$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')
->will($this
->returnValue([]));
$query
->expects($this
->any())
->method('condition')
->will($this
->returnValue($query));
$storage
->expects($this
->any())
->method('getQuery')
->will($this
->returnValue($query));
$storage
->expects($this
->any())
->method('loadUnchanged')
->will($this
->returnValue($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']);
}