function ConfigEntityQueryTest::testAlterHook
Same name in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityQueryTest::testAlterHook()
Test the entity query alter hooks are invoked.
See also
config_test_entity_query_tag__config_query_test__config_entity_query_alter_hook_test_alter()
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ ConfigEntityQueryTest.php, line 765
Class
- ConfigEntityQueryTest
- Tests Config Entity Query functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testAlterHook() : void {
// Run a test without any condition.
$this->queryResults = $this->entityStorage
->getQuery()
->execute();
$this->assertResults([
'1',
'2',
'3',
'4',
'5',
'6',
'7',
]);
// config_test alter hook removes the entity with id '7'.
$this->queryResults = $this->entityStorage
->getQuery()
->addTag('config_entity_query_alter_hook_test')
->execute();
$this->assertResults([
'1',
'2',
'3',
'4',
'5',
'6',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.