function EntityKernelTestBase::setUp

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::setUp()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::setUp()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::setUp()

Overrides KernelTestBase::setUp

67 calls to EntityKernelTestBase::setUp()
CommentDefaultFormatterCacheTagsTest::setUp in core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php
CommentFieldAccessTest::setUp in core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php
CommentLegacyTest::setUp in core/modules/comment/tests/src/Kernel/CommentLegacyTest.php
CommentOrphanTest::setUp in core/modules/comment/tests/src/Kernel/CommentOrphanTest.php
CommentValidationTest::setUp in core/modules/comment/tests/src/Kernel/CommentValidationTest.php

... See full list

67 methods override EntityKernelTestBase::setUp()
CommentDefaultFormatterCacheTagsTest::setUp in core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php
CommentFieldAccessTest::setUp in core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php
CommentLegacyTest::setUp in core/modules/comment/tests/src/Kernel/CommentLegacyTest.php
CommentOrphanTest::setUp in core/modules/comment/tests/src/Kernel/CommentOrphanTest.php
CommentValidationTest::setUp in core/modules/comment/tests/src/Kernel/CommentValidationTest.php

... See full list

File

core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php, line 67

Class

EntityKernelTestBase
Defines an abstract test base for entity kernel tests.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function setUp() {
    parent::setUp();
    $this->entityTypeManager = $this->container
        ->get('entity_type.manager');
    $this->state = $this->container
        ->get('state');
    $this->installSchema('system', 'sequences');
    $this->installEntitySchema('user');
    $this->installEntitySchema('entity_test');
    // If the concrete test sub-class installs the Node or Comment modules,
    // ensure that the node and comment entity schema are created before the
    // field configurations are installed. This is because the entity tables
    // need to be created before the body field storage tables. This prevents
    // trying to create the body field tables twice.
    $class = get_class($this);
    while ($class) {
        if (property_exists($class, 'modules')) {
            // Only check the modules, if the $modules property was not inherited.
            $rp = new \ReflectionProperty($class, 'modules');
            if ($rp->class == $class) {
                foreach (array_intersect([
                    'node',
                    'comment',
                ], $class::$modules) as $module) {
                    $this->installEntitySchema($module);
                }
                if (in_array('forum', $class::$modules, TRUE)) {
                    // Forum module is particular about the order that dependencies are
                    // enabled in. The comment, node and taxonomy config and the
                    // taxonomy_term schema need to be installed before the forum config
                    // which in turn needs to be installed before field config.
                    $this->installEntitySchema('taxonomy_term');
                    $this->installConfig([
                        'comment',
                        'node',
                        'taxonomy',
                    ]);
                    $this->installConfig([
                        'forum',
                    ]);
                }
            }
        }
        $class = get_parent_class($class);
    }
    $this->installConfig([
        'field',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.