public function ConfigEntityBaseUnitTest::testPreSaveDuringSync in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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 160 - 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() {
$query = $this
->getMock('\\Drupal\\Core\\Entity\\Query\\QueryInterface');
$storage = $this
->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
$query
->expects($this
->any())
->method('execute')
->will($this
->returnValue(array()));
$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', array(
'module' => array(
'node',
),
));
$this->entity
->preSave($storage);
$this
->assertEmpty($this->entity
->getDependencies());
$this->entity
->setSyncing(TRUE);
$this->entity
->set('dependencies', array(
'module' => array(
'node',
),
));
$this->entity
->preSave($storage);
$dependencies = $this->entity
->getDependencies();
$this
->assertContains('node', $dependencies['module']);
}