protected function TestCoverageTest::setUp in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/TestCoverageTest.php \Drupal\Tests\jsonapi\Functional\TestCoverageTest::setUp()
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ TestCoverageTest.php, line 25
Class
- TestCoverageTest
- Checks that all core content/config entity types have JSON API test coverage.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function setUp() {
parent::setUp();
$all_modules = system_rebuild_module_data();
$stable_core_modules = array_filter($all_modules, function ($module) {
// Filter out contrib, hidden, testing, and experimental modules. We also
// don't need to enable modules that are already enabled.
return $module->origin === 'core' && empty($module->info['hidden']) && $module->status == FALSE && $module->info['package'] !== 'Testing' && $module->info['package'] !== 'Core (Experimental)';
});
$this->container
->get('module_installer')
->install(array_keys($stable_core_modules));
$this
->rebuildContainer();
$this->definitions = $this->container
->get('entity_type.manager')
->getDefinitions();
// @todo Remove this when JSON API requires Drupal 8.5 or newer.
if (floatval(\Drupal::VERSION) < 8.5) {
return;
}
// Entity types marked as "internal" are not exposed by JSON API and hence
// also don't need test coverage.
$this->definitions = array_filter($this->definitions, function (EntityTypeInterface $entity_type) {
return !$entity_type
->isInternal();
});
}