public function EntityValidationTest::testValidation in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/EntityValidationTest.php \Drupal\system\Tests\Entity\EntityValidationTest::testValidation()
Tests validating test entity types.
File
- core/
modules/ system/ src/ Tests/ Entity/ EntityValidationTest.php, line 86 - Contains \Drupal\system\Tests\Entity\EntityValidationTest.
Class
- EntityValidationTest
- Tests the Entity Validation API.
Namespace
Drupal\system\Tests\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
->assertTrue(in_array('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);
}
}