You are here

protected function EntityUnitTestBase::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityUnitTestBase.php \Drupal\system\Tests\Entity\EntityUnitTestBase::setUp()

Performs setup tasks before each individual test method is run.

Overrides KernelTestBase::setUp

44 calls to EntityUnitTestBase::setUp()
CommentDefaultFormatterCacheTagsTest::setUp in core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php
Performs setup tasks before each individual test method is run.
CommentFieldAccessTest::setUp in core/modules/comment/src/Tests/CommentFieldAccessTest.php
Performs setup tasks before each individual test method is run.
CommentValidationTest::setUp in core/modules/comment/src/Tests/CommentValidationTest.php
Performs setup tasks before each individual test method is run.
ContentEntityChangedTest::setUp in core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php
@inheritdoc
ContentEntityCloneTest::setUp in core/modules/system/src/Tests/Entity/ContentEntityCloneTest.php
Performs setup tasks before each individual test method is run.

... See full list

44 methods override EntityUnitTestBase::setUp()
CommentDefaultFormatterCacheTagsTest::setUp in core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php
Performs setup tasks before each individual test method is run.
CommentFieldAccessTest::setUp in core/modules/comment/src/Tests/CommentFieldAccessTest.php
Performs setup tasks before each individual test method is run.
CommentValidationTest::setUp in core/modules/comment/src/Tests/CommentValidationTest.php
Performs setup tasks before each individual test method is run.
ContentEntityChangedTest::setUp in core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php
@inheritdoc
ContentEntityCloneTest::setUp in core/modules/system/src/Tests/Entity/ContentEntityCloneTest.php
Performs setup tasks before each individual test method is run.

... See full list

File

core/modules/system/src/Tests/Entity/EntityUnitTestBase.php, line 46
Contains \Drupal\system\Tests\Entity\EntityUnitTestBase.

Class

EntityUnitTestBase
Defines an abstract test base for entity unit tests.

Namespace

Drupal\system\Tests\Entity

Code

protected function setUp() {
  parent::setUp();
  $this->entityManager = $this->container
    ->get('entity.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(array(
          '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
            ->installConfig([
            'comment',
            'node',
            'taxonomy',
          ]);
          $this
            ->installEntitySchema('taxonomy_term');
          $this
            ->installConfig([
            'forum',
          ]);
        }
      }
    }
    $class = get_parent_class($class);
  }
  $this
    ->installConfig(array(
    'field',
  ));
}