function EntityReferenceRelationshipTest::setUp

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\EntityReferenceRelationshipTest::setUp()
  2. 8.9.x core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\EntityReferenceRelationshipTest::setUp()
  3. 10 core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\EntityReferenceRelationshipTest::setUp()

Overrides ViewsKernelTestBase::setUp

File

core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php, line 62

Class

EntityReferenceRelationshipTest
Tests entity reference relationship data.

Namespace

Drupal\Tests\field\Kernel\EntityReference\Views

Code

protected function setUp($import_test_views = TRUE) : void {
    parent::setUp();
    $this->installEntitySchema('user');
    $this->installEntitySchema('user_role');
    $this->installEntitySchema('entity_test');
    $this->installEntitySchema('entity_test_mul');
    $this->installEntitySchema('entity_test_mul_changed');
    // Create reference from entity_test to entity_test_mul.
    $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_data', 'field_test_data', 'entity_test_mul');
    // Create reference from entity_test_mul to entity_test.
    $this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test', 'field_data_test', 'entity_test');
    // Create another field for testing with a long name. So its storage name
    // will become hashed. Use entity_test_mul_changed, so the resulting field
    // tables created will be greater than 48 chars long.
    // @see \Drupal\Core\Entity\Sql\DefaultTableMapping::generateFieldTableName()
    $this->createEntityReferenceField('entity_test_mul_changed', 'entity_test_mul_changed', 'field_test_data_with_a_long_name', 'field_test_data_with_a_long_name', 'entity_test');
    // Create reference from entity_test_mul to entity_test cardinality: infinite.
    $this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test_unlimited', 'field_data_test_unlimited', 'entity_test', 'default', [], FieldStorageConfig::CARDINALITY_UNLIMITED);
    ViewTestData::createTestViews(static::class, [
        'entity_reference_test_views',
    ]);
}

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