Chris@18: origin === 'core' Chris@18: && empty($module->info['hidden']) Chris@18: && $module->status == FALSE Chris@18: && $module->info['package'] !== 'Testing' Chris@18: && $module->info['package'] !== 'Core (Experimental)'; Chris@18: }); Chris@18: Chris@18: $this->container->get('module_installer')->install(array_keys($stable_core_modules)); Chris@18: $this->rebuildContainer(); Chris@18: Chris@18: $this->definitions = $this->container->get('entity_type.manager')->getDefinitions(); Chris@18: Chris@18: // Entity types marked as "internal" are not exposed by JSON:API and hence Chris@18: // also don't need test coverage. Chris@18: $this->definitions = array_filter($this->definitions, function (EntityTypeInterface $entity_type) { Chris@18: return !$entity_type->isInternal(); Chris@18: }); Chris@18: } Chris@18: Chris@18: /** Chris@18: * Tests that all core entity types have JSON:API test coverage. Chris@18: */ Chris@18: public function testEntityTypeRestTestCoverage() { Chris@18: $problems = []; Chris@18: foreach ($this->definitions as $entity_type_id => $info) { Chris@18: $class_name_full = $info->getClass(); Chris@18: $parts = explode('\\', $class_name_full); Chris@18: $class_name = end($parts); Chris@18: $module_name = $parts[1]; Chris@18: Chris@18: $possible_paths = [ Chris@18: 'Drupal\Tests\jsonapi\Functional\CLASSTest', Chris@18: '\Drupal\Tests\\' . $module_name . '\Functional\Jsonapi\CLASSTest', Chris@18: ]; Chris@18: foreach ($possible_paths as $path) { Chris@18: $missing_tests = []; Chris@18: $class = str_replace('CLASS', $class_name, $path); Chris@18: if (class_exists($class)) { Chris@18: continue 2; Chris@18: } Chris@18: $missing_tests[] = $class; Chris@18: } Chris@18: if (!empty($missing_tests)) { Chris@18: $missing_tests_list = implode(', ', $missing_tests); Chris@18: $problems[] = "$entity_type_id: $class_name ($class_name_full) (expected tests: $missing_tests_list)"; Chris@18: } Chris@18: } Chris@18: Chris@18: $all = count($this->definitions); Chris@18: $good = $all - count($problems); Chris@18: $this->assertSame([], $problems, $this->getLlamaMessage($good, $all)); Chris@18: } Chris@18: Chris@18: /** Chris@18: * Message from Llama. Chris@18: * Chris@18: * @param int $g Chris@18: * A count of entities with test coverage. Chris@18: * @param int $a Chris@18: * A count of all entities. Chris@18: * Chris@18: * @return string Chris@18: * An information about progress of REST test coverage. Chris@18: */ Chris@18: protected function getLlamaMessage($g, $a) { Chris@18: return " Chris@18: ☼ Chris@18: _________________________ Chris@18: / Hi! \\ Chris@18: | It's llame to not have | Chris@18: | complete JSON:API tests! | Chris@18: | | Chris@18: | Progress: $g/$a. | Chris@18: | _________________________/ Chris@18: |/ Chris@18: // o Chris@18: l'> Chris@18: ll Chris@18: llama Chris@18: || || Chris@18: '' '' Chris@18: "; Chris@18: } Chris@18: Chris@18: }