function entity_test_entity_types

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_types()
  2. 8.9.x core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_types()
  3. 10 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_types()

Returns a list of test entity types.

The returned entity types are one for each available entity storage type:

  • The plain entity_test type supports neither revisions nor multilingual properties.
  • The entity_test_mul type supports multilingual properties.
  • The entity_test_rev type supports revisions.
  • The entity_test_mulrev type supports both revisions and multilingual properties.

Parameters

int $filter: Either ENTITY_TEST_TYPES_REVISABLE to only return revisable entity types or ENTITY_TEST_TYPES_MULTILINGUAL to only return multilingual ones. Defaults to NULL, which returns all.

Return value

array List with entity_types.

29 calls to entity_test_entity_types()
EntityApiTest::setUp in core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
EntityApiTest::testCRUD in core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
Tests basic CRUD functionality of the Entity API.
EntityDisplayFormBaseTest::setUp in core/modules/field_ui/tests/src/Functional/EntityDisplayFormBaseTest.php
EntityFieldDefaultValueTest::testDefaultValues in core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
Tests default values on entities and fields.
EntityFieldTest::setUp in core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php

... See full list

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 58

Code

function entity_test_entity_types($filter = NULL) {
    $types = [];
    if ($filter === NULL || $filter === ENTITY_TEST_TYPES_ROUTING) {
        $types[] = 'entity_test';
    }
    if ($filter != ENTITY_TEST_TYPES_REVISABLE) {
        $types[] = 'entity_test_mul';
        $types[] = 'entity_test_mul_langcode_key';
        $types[] = 'entity_test_mul_changed';
    }
    if ($filter != ENTITY_TEST_TYPES_MULTILINGUAL) {
        $types[] = 'entity_test_rev';
    }
    if ($filter === ENTITY_TEST_TYPES_ROUTING) {
        $types[] = 'entity_test_base_field_display';
        $types[] = 'entity_test_string_id';
        $types[] = 'entity_test_no_id';
        $types[] = 'entity_test_mul_with_bundle';
    }
    $types[] = 'entity_test_mulrev';
    $types[] = 'entity_test_mulrev_changed';
    return array_combine($types, $types);
}

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