* Tests that all core content/config entity types have REST test coverage.
*/
public function testEntityTypeRestTestCoverage() {
- $default_test_locations = [
+ $tests = [
// Test coverage for formats provided by the 'serialization' module.
'serialization' => [
- 'possible paths' => [
- '\Drupal\Tests\rest\Functional\EntityResource\CLASS\CLASS',
- ],
+ 'path' => '\Drupal\Tests\PROVIDER\Functional\Rest\CLASS',
'class suffix' => [
'JsonAnonTest',
'JsonBasicAuthTest',
],
// Test coverage for formats provided by the 'hal' module.
'hal' => [
- 'possible paths' => [
- '\Drupal\Tests\hal\Functional\EntityResource\CLASS\CLASS',
- ],
+ 'path' => '\Drupal\Tests\PROVIDER\Functional\Hal\CLASS',
'class suffix' => [
'HalJsonAnonTest',
'HalJsonBasicAuthTest',
$class_name = end($parts);
$module_name = $parts[1];
- // The test class can live either in the REST/HAL module, or in the module
- // providing the entity type.
- $tests = $default_test_locations;
- $tests['serialization']['possible paths'][] = '\Drupal\Tests\\' . $module_name . '\Functional\Rest\CLASS';
- $tests['hal']['possible paths'][] = '\Drupal\Tests\\' . $module_name . '\Functional\Hal\CLASS';
-
foreach ($tests as $module => $info) {
- $possible_paths = $info['possible paths'];
+ $path = $info['path'];
$missing_tests = [];
foreach ($info['class suffix'] as $postfix) {
- foreach ($possible_paths as $path) {
- $class = str_replace('CLASS', $class_name, $path . $postfix);
- if (class_exists($class)) {
- continue 2;
- }
+ $class = str_replace(['PROVIDER', 'CLASS'], [$module_name, $class_name], $path . $postfix);
+ $class_alternative = str_replace("\\Drupal\\Tests\\$module_name\\Functional", '\Drupal\FunctionalTests', $class);
+ if (class_exists($class) || class_exists($class_alternative)) {
+ continue;
}
$missing_tests[] = $postfix;
}