public function TestCoverageTest::testEntityTypeRestTestCoverage in JSON:API 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/TestCoverageTest.php \Drupal\Tests\jsonapi\Functional\TestCoverageTest::testEntityTypeRestTestCoverage()
Tests that all core entity types have JSON:API test coverage.
File
- tests/
src/ Functional/ TestCoverageTest.php, line 54
Class
- TestCoverageTest
- Checks that all core content/config entity types have JSON:API test coverage.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testEntityTypeRestTestCoverage() {
$problems = [];
foreach ($this->definitions as $entity_type_id => $info) {
$class_name_full = $info
->getClass();
$parts = explode('\\', $class_name_full);
$class_name = end($parts);
$module_name = $parts[1];
$possible_paths = [
'Drupal\\Tests\\jsonapi\\Functional\\CLASSTest',
'\\Drupal\\Tests\\' . $module_name . '\\Functional\\Jsonapi\\CLASSTest',
];
foreach ($possible_paths as $path) {
$missing_tests = [];
$class = str_replace('CLASS', $class_name, $path);
if (class_exists($class)) {
continue 2;
}
$missing_tests[] = $class;
}
if (!empty($missing_tests)) {
$missing_tests_list = implode(', ', $missing_tests);
$problems[] = "{$entity_type_id}: {$class_name} ({$class_name_full}) (expected tests: {$missing_tests_list})";
}
}
$all = count($this->definitions);
$good = $all - count($problems);
$this
->assertSame([], $problems, $this
->getLlamaMessage($good, $all));
}