You are here

protected function TestCoverageTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/TestCoverageTest.php \Drupal\Tests\jsonapi\Functional\TestCoverageTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/jsonapi/tests/src/Functional/TestCoverageTest.php, line 30

Class

TestCoverageTest
Checks that all core content/config entity types have JSON:API test coverage.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function setUp() {
  parent::setUp();
  $all_modules = \Drupal::service('extension.list.module')
    ->getList();
  $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();

  // 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();
  });
}