public function EntityValidationTest::testValidation in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php \Drupal\KernelTests\Core\Entity\EntityValidationTest::testValidation()
Tests validating test entity types.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityValidationTest.php, line 95
Class
- EntityValidationTest
- Tests the Entity Validation API.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testValidation() {
// Ensure that the constraint manager is marked as cached cleared.
// Use the protected property on the cache_clearer first to check whether
// the constraint manager is added there.
// Ensure that the proxy class is initialized, which has the necessary
// method calls attached.
\Drupal::service('plugin.cache_clearer');
$plugin_cache_clearer = \Drupal::service('drupal.proxy_original_service.plugin.cache_clearer');
$get_cached_discoveries = function () {
return $this->cachedDiscoveries;
};
$get_cached_discoveries = $get_cached_discoveries
->bindTo($plugin_cache_clearer, $plugin_cache_clearer);
$cached_discoveries = $get_cached_discoveries();
$cached_discovery_classes = [];
foreach ($cached_discoveries as $cached_discovery) {
$cached_discovery_classes[] = get_class($cached_discovery);
}
$this
->assertContains('Drupal\\Core\\Validation\\ConstraintManager', $cached_discovery_classes);
// All entity variations have to have the same results.
foreach (entity_test_entity_types() as $entity_type) {
$this
->checkValidation($entity_type);
}
}