class EntitySchemaTest in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php \Drupal\KernelTests\Core\Entity\EntitySchemaTest
Tests the default entity storage schema handler.
@group Entity
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, AssertLegacyTrait, ConfigTestTrait, ExtensionListTestTrait, PhpUnitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses UserCreationTrait
- class \Drupal\KernelTests\Core\Entity\EntitySchemaTest uses EntityDefinitionTestTrait
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses UserCreationTrait
Expanded class hierarchy of EntitySchemaTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntitySchemaTest.php, line 15
Namespace
Drupal\KernelTests\Core\EntityView source
class EntitySchemaTest extends EntityKernelTestBase {
use EntityDefinitionTestTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_test_update',
];
/**
* The database connection used.
*
* @var \Drupal\Core\Database\Connection
*/
protected $database;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this
->installSchema('user', [
'users_data',
]);
$this
->installEntitySchema('entity_test_update');
$this->database = $this->container
->get('database');
}
/**
* Tests the custom bundle field creation and deletion.
*/
public function testCustomFieldCreateDelete() {
// Install the module which adds the field.
$this
->installModule('entity_schema_test');
$storage_definitions = \Drupal::service('entity_field.manager')
->getFieldStorageDefinitions('entity_test_update');
$this
->assertNotNull($storage_definitions['custom_base_field'], 'Base field definition found.');
$this
->assertNotNull($storage_definitions['custom_bundle_field'], 'Bundle field definition found.');
// Make sure the field schema can be created.
\Drupal::service('field_storage_definition.listener')
->onFieldStorageDefinitionCreate($storage_definitions['custom_base_field']);
\Drupal::service('field_storage_definition.listener')
->onFieldStorageDefinitionCreate($storage_definitions['custom_bundle_field']);
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = $this->entityTypeManager
->getStorage('entity_test_update')
->getTableMapping();
$base_table = current($table_mapping
->getTableNames());
$base_column = current($table_mapping
->getColumnNames('custom_base_field'));
$this
->assertTrue($this->database
->schema()
->fieldExists($base_table, $base_column), 'Table column created');
$table = $table_mapping
->getDedicatedDataTableName($storage_definitions['custom_bundle_field']);
$this
->assertTrue($this->database
->schema()
->tableExists($table), 'Table created');
// Make sure the field schema can be deleted.
\Drupal::service('field_storage_definition.listener')
->onFieldStorageDefinitionDelete($storage_definitions['custom_base_field']);
\Drupal::service('field_storage_definition.listener')
->onFieldStorageDefinitionDelete($storage_definitions['custom_bundle_field']);
$this
->assertFalse($this->database
->schema()
->fieldExists($base_table, $base_column), 'Table column dropped');
$this
->assertFalse($this->database
->schema()
->tableExists($table), 'Table dropped');
}
/**
* Updates the entity type definition.
*
* @param bool $alter
* Whether the original definition should be altered or not.
*/
protected function updateEntityType($alter) {
$this->state
->set('entity_schema_update', $alter);
$updated_entity_type = $this
->getUpdatedEntityTypeDefinition($alter, $alter);
$updated_field_storage_definitions = $this
->getUpdatedFieldStorageDefinitions($alter, $alter);
$this->container
->get('entity.definition_update_manager')
->updateFieldableEntityType($updated_entity_type, $updated_field_storage_definitions);
}
/**
* Tests that entity schema responds to changes in the entity type definition.
*/
public function testEntitySchemaUpdate() {
$this
->installModule('entity_schema_test');
$storage_definitions = \Drupal::service('entity_field.manager')
->getFieldStorageDefinitions('entity_test_update');
\Drupal::service('field_storage_definition.listener')
->onFieldStorageDefinitionCreate($storage_definitions['custom_base_field']);
\Drupal::service('field_storage_definition.listener')
->onFieldStorageDefinitionCreate($storage_definitions['custom_bundle_field']);
$schema_handler = $this->database
->schema();
$tables = [
'entity_test_update',
'entity_test_update_revision',
'entity_test_update_data',
'entity_test_update_revision_data',
];
$dedicated_tables = [
'entity_test_update__custom_bundle_field',
'entity_test_update_revision__custom_bundle_field',
];
// Initially only the base table and the dedicated field data table should
// exist.
foreach ($tables as $index => $table) {
$this
->assertEquals(!$index, $schema_handler
->tableExists($table), new FormattableMarkup('Entity schema correct for the @table table.', [
'@table' => $table,
]));
}
$this
->assertTrue($schema_handler
->tableExists($dedicated_tables[0]), new FormattableMarkup('Field schema correct for the @table table.', [
'@table' => $table,
]));
// Update the entity type definition and check that the entity schema now
// supports translations and revisions.
$this
->updateEntityType(TRUE);
foreach ($tables as $table) {
$this
->assertTrue($schema_handler
->tableExists($table), new FormattableMarkup('Entity schema correct for the @table table.', [
'@table' => $table,
]));
}
foreach ($dedicated_tables as $table) {
$this
->assertTrue($schema_handler
->tableExists($table), new FormattableMarkup('Field schema correct for the @table table.', [
'@table' => $table,
]));
}
// Revert changes and check that the entity schema now does not support
// neither translations nor revisions.
$this
->updateEntityType(FALSE);
foreach ($tables as $index => $table) {
$this
->assertEquals(!$index, $schema_handler
->tableExists($table), new FormattableMarkup('Entity schema correct for the @table table.', [
'@table' => $table,
]));
}
$this
->assertTrue($schema_handler
->tableExists($dedicated_tables[0]), new FormattableMarkup('Field schema correct for the @table table.', [
'@table' => $table,
]));
}
/**
* Tests deleting and creating a field that is part of a primary key.
*
* @param string $entity_type_id
* The ID of the entity type whose schema is being tested.
* @param string $field_name
* The name of the field that is being re-installed.
*
* @dataProvider providerTestPrimaryKeyUpdate
*/
public function testPrimaryKeyUpdate($entity_type_id, $field_name) {
// EntityKernelTestBase::setUp() already installs the schema for the
// 'entity_test' entity type.
if ($entity_type_id !== 'entity_test') {
$this
->installEntitySchema($entity_type_id);
}
/** @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface $update_manager */
$update_manager = $this->container
->get('entity.definition_update_manager');
$entity_type = $update_manager
->getEntityType($entity_type_id);
/* @see \Drupal\Core\Entity\ContentEntityBase::baseFieldDefinitions() */
switch ($field_name) {
case 'id':
$field = BaseFieldDefinition::create('integer')
->setLabel('ID')
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
break;
case 'revision_id':
$field = BaseFieldDefinition::create('integer')
->setLabel('Revision ID')
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
break;
case 'langcode':
$field = BaseFieldDefinition::create('language')
->setLabel('Language');
if ($entity_type
->isRevisionable()) {
$field
->setRevisionable(TRUE);
}
if ($entity_type
->isTranslatable()) {
$field
->setTranslatable(TRUE);
}
break;
}
$field
->setName($field_name)
->setTargetEntityTypeId($entity_type_id)
->setProvider($entity_type
->getProvider());
// Build up a map of expected primary keys depending on the entity type
// configuration.
$id_key = $entity_type
->getKey('id');
$revision_key = $entity_type
->getKey('revision');
$langcode_key = $entity_type
->getKey('langcode');
$expected = [];
$expected[$entity_type
->getBaseTable()] = [
$id_key,
];
if ($entity_type
->isRevisionable()) {
$expected[$entity_type
->getRevisionTable()] = [
$revision_key,
];
}
if ($entity_type
->isTranslatable()) {
$expected[$entity_type
->getDataTable()] = [
$id_key,
$langcode_key,
];
}
if ($entity_type
->isRevisionable() && $entity_type
->isTranslatable()) {
$expected[$entity_type
->getRevisionDataTable()] = [
$revision_key,
$langcode_key,
];
}
// First, test explicitly deleting and re-installing a field. Make sure that
// all primary keys are there to start with.
$this
->assertSame($expected, $this
->findPrimaryKeys($entity_type));
// Then uninstall the field and make sure all primary keys that the field
// was part of have been updated. Since this is not a valid state of the
// entity type (for example a revisionable entity type without a revision ID
// field or a translatable entity type without a language code field) the
// actual primary keys at this point are irrelevant.
$update_manager
->uninstallFieldStorageDefinition($field);
$this
->assertNotEquals($expected, $this
->findPrimaryKeys($entity_type));
// Finally, reinstall the field and make sure the primary keys have been
// recreated.
$update_manager
->installFieldStorageDefinition($field
->getName(), $entity_type_id, $field
->getProvider(), $field);
$this
->assertSame($expected, $this
->findPrimaryKeys($entity_type));
// Now test updating a field without data. This will end up deleting
// and re-creating the field, similar to the code above.
$update_manager
->updateFieldStorageDefinition($field);
$this
->assertSame($expected, $this
->findPrimaryKeys($entity_type));
// Now test updating a field with data.
/** @var \Drupal\Core\Entity\FieldableEntityStorageInterface $storage */
$storage = $this->entityTypeManager
->getStorage($entity_type_id);
$storage
->create()
->save();
$this
->assertTrue($storage
->countFieldData($field, TRUE));
$update_manager
->updateFieldStorageDefinition($field);
$this
->assertSame($expected, $this
->findPrimaryKeys($entity_type));
$this
->assertTrue($storage
->countFieldData($field, TRUE));
}
/**
* Finds the primary keys for a given entity type.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type whose primary keys are being fetched.
*
* @return array[]
* An array where the keys are the table names of the entity type's tables
* and the values are a list of the respective primary keys.
*/
protected function findPrimaryKeys(EntityTypeInterface $entity_type) {
$base_table = $entity_type
->getBaseTable();
$revision_table = $entity_type
->getRevisionTable();
$data_table = $entity_type
->getDataTable();
$revision_data_table = $entity_type
->getRevisionDataTable();
$schema = $this->database
->schema();
$find_primary_key_columns = new \ReflectionMethod(get_class($schema), 'findPrimaryKeyColumns');
$find_primary_key_columns
->setAccessible(TRUE);
// Build up a map of primary keys depending on the entity type
// configuration. If the field that is being removed is part of a table's
// primary key, we skip the assertion for that table as this represents an
// intermediate and invalid state of the entity schema.
$primary_keys[$base_table] = $find_primary_key_columns
->invoke($schema, $base_table);
if ($entity_type
->isRevisionable()) {
$primary_keys[$revision_table] = $find_primary_key_columns
->invoke($schema, $revision_table);
}
if ($entity_type
->isTranslatable()) {
$primary_keys[$data_table] = $find_primary_key_columns
->invoke($schema, $data_table);
}
if ($entity_type
->isRevisionable() && $entity_type
->isTranslatable()) {
$primary_keys[$revision_data_table] = $find_primary_key_columns
->invoke($schema, $revision_data_table);
}
return $primary_keys;
}
/**
* Provides test cases for EntitySchemaTest::testPrimaryKeyUpdate()
*
* @return array
* An array of test cases consisting of an entity type ID and a field name.
*/
public function providerTestPrimaryKeyUpdate() {
// Build up test cases for all possible entity type configurations.
// For each entity type we test reinstalling each field that is part of
// any table's primary key.
$tests = [];
$tests['entity_test:id'] = [
'entity_test',
'id',
];
$tests['entity_test_rev:id'] = [
'entity_test_rev',
'id',
];
$tests['entity_test_rev:revision_id'] = [
'entity_test_rev',
'revision_id',
];
$tests['entity_test_mul:id'] = [
'entity_test_mul',
'id',
];
$tests['entity_test_mul:langcode'] = [
'entity_test_mul',
'langcode',
];
$tests['entity_test_mulrev:id'] = [
'entity_test_mulrev',
'id',
];
$tests['entity_test_mulrev:revision_id'] = [
'entity_test_mulrev',
'revision_id',
];
$tests['entity_test_mulrev:langcode'] = [
'entity_test_mulrev',
'langcode',
];
return $tests;
}
/**
* {@inheritdoc}
*/
protected function refreshServices() {
parent::refreshServices();
$this->database = $this->container
->get('database');
}
/**
* Tests that modifying the UUID field for a translatable entity works.
*/
public function testModifyingTranslatableColumnSchema() {
$this
->installModule('entity_schema_test');
$this
->updateEntityType(TRUE);
$fields = [
'revision_log',
'uuid',
];
$entity_field_manager = \Drupal::service('entity_field.manager');
foreach ($fields as $field_name) {
$original_definition = $entity_field_manager
->getBaseFieldDefinitions('entity_test_update')[$field_name];
$new_definition = clone $original_definition;
$new_definition
->setLabel($original_definition
->getLabel() . ', the other one');
$this
->assertTrue($this->entityTypeManager
->getStorage('entity_test_update')
->requiresFieldDataMigration($new_definition, $original_definition));
}
}
/**
* Tests fields from an uninstalled module are removed from the schema.
*/
public function testCleanUpStorageDefinition() {
// Find all the entity types provided by the entity_test module and install
// the schema for them.
$entity_type_ids = [];
$entities = \Drupal::entityTypeManager()
->getDefinitions();
foreach ($entities as $entity_type_id => $definition) {
if ($definition
->getProvider() == 'entity_test') {
$this
->installEntitySchema($entity_type_id);
$entity_type_ids[] = $entity_type_id;
}
}
// Get a list of all the entities in the schema.
$key_value_store = \Drupal::keyValue('entity.storage_schema.sql');
$schema = $key_value_store
->getAll();
// Count the storage definitions provided by the entity_test module, so that
// after uninstall we can be sure there were some to be deleted.
$entity_type_id_count = 0;
foreach (array_keys($schema) as $storage_definition_name) {
list($entity_type_id, , ) = explode('.', $storage_definition_name);
if (in_array($entity_type_id, $entity_type_ids)) {
$entity_type_id_count++;
}
}
// Ensure that there are storage definitions from the entity_test module.
$this
->assertNotEquals(0, $entity_type_id_count, 'There are storage definitions provided by the entity_test module in the schema.');
// Uninstall the entity_test module.
$this->container
->get('module_installer')
->uninstall([
'entity_test',
]);
// Get a list of all the entities in the schema.
$key_value_store = \Drupal::keyValue('entity.storage_schema.sql');
$schema = $key_value_store
->getAll();
// Count the storage definitions that come from entity types provided by
// the entity_test module.
$entity_type_id_count = 0;
foreach (array_keys($schema) as $storage_definition_name) {
list($entity_type_id, , ) = explode('.', $storage_definition_name);
if (in_array($entity_type_id, $entity_type_ids)) {
$entity_type_id_count++;
}
}
// Ensure that all storage definitions have been removed from the schema.
$this
->assertEquals(0, $entity_type_id_count, 'After uninstalling entity_test module the schema should not contains fields from entities provided by the module.');
}
/**
* Tests the installed storage schema for identifier fields.
*/
public function testIdentifierSchema() {
$this
->installEntitySchema('entity_test_rev');
$key_value_store = \Drupal::keyValue('entity.storage_schema.sql');
$id_schema = $key_value_store
->get('entity_test_rev.field_schema_data.id', []);
$revision_id_schema = $key_value_store
->get('entity_test_rev.field_schema_data.revision_id', []);
$expected_id_schema = [
'entity_test_rev' => [
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => TRUE,
],
],
],
'entity_test_rev_revision' => [
'fields' => [
'id' => [
'type' => 'int',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => TRUE,
],
],
],
];
$this
->assertEquals($expected_id_schema, $id_schema);
$expected_revision_id_schema = [
'entity_test_rev' => [
'fields' => [
'revision_id' => [
'type' => 'int',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => FALSE,
],
],
],
'entity_test_rev_revision' => [
'fields' => [
'revision_id' => [
'type' => 'serial',
'unsigned' => TRUE,
'size' => 'normal',
'not null' => TRUE,
],
],
],
];
$this
->assertEquals($expected_revision_id_schema, $revision_id_schema);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertContentTrait:: |
protected | property | The current raw content. | |
AssertContentTrait:: |
protected | property | The drupalSettings value from the current raw $content. | |
AssertContentTrait:: |
protected | property | The XML structure parsed from the current raw $content. | 1 |
AssertContentTrait:: |
protected | property | The plain-text content of raw $content (text nodes). | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertContentTrait:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href is not found in the main region. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page does not exist. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertContentTrait:: |
protected | function | Pass if the page title is not the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertContentTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertContentTrait:: |
protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | |
AssertContentTrait:: |
protected | function | Asserts themed output. | |
AssertContentTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
AssertContentTrait:: |
protected | function | Builds an XPath query. | |
AssertContentTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertContentTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
AssertContentTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertContentTrait:: |
protected | function | Gets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Gets the current raw content. | |
AssertContentTrait:: |
protected | function | Get the selected value from a select field. | |
AssertContentTrait:: |
protected | function | Retrieves the plain-text content from the current raw content. | |
AssertContentTrait:: |
protected | function | Get the current URL from the cURL handler. | 1 |
AssertContentTrait:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
AssertContentTrait:: |
protected | function | Removes all white-space between HTML tags from the raw content. | |
AssertContentTrait:: |
protected | function | Sets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Sets the raw content (e.g. HTML). | |
AssertContentTrait:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
AssertLegacyTrait:: |
protected | function | ||
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
EntityDefinitionTestTrait:: |
protected | function | Adds a new base field to the 'entity_test_update' entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Adds a single-field index to the base field. | |
EntityDefinitionTestTrait:: |
protected | function | Adds a new bundle field to the 'entity_test_update' entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Adds an index to the 'entity_test_update' entity type's base table. | |
EntityDefinitionTestTrait:: |
protected | function | Adds a long-named base field to the 'entity_test_update' entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Adds a new revisionable base field to the 'entity_test_update' entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Applies all the detected valid changes. | |
EntityDefinitionTestTrait:: |
protected | function | Removes the entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Performs an entity type definition update. | |
EntityDefinitionTestTrait:: |
protected | function | Performs a field storage definition update. | |
EntityDefinitionTestTrait:: |
protected | function | Enables a new entity type definition. | |
EntityDefinitionTestTrait:: |
protected | function | Returns an entity type definition, possibly updated to be rev or mul. | |
EntityDefinitionTestTrait:: |
protected | function | Returns the required rev / mul field definitions for an entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Promotes a field to an entity key. | |
EntityDefinitionTestTrait:: |
protected | function | Modifies the new base field from 'string' to 'text'. | |
EntityDefinitionTestTrait:: |
protected | function | Modifies the new bundle field from 'string' to 'text'. | |
EntityDefinitionTestTrait:: |
protected | function | Removes the new base field from the 'entity_test_update' entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Removes the index added in addBaseFieldIndex(). | |
EntityDefinitionTestTrait:: |
protected | function | Removes the new bundle field from the 'entity_test_update' entity type. | |
EntityDefinitionTestTrait:: |
protected | function | Removes the index added in addEntityIndex(). | |
EntityDefinitionTestTrait:: |
protected | function | Renames the base table to 'entity_test_update_new'. | |
EntityDefinitionTestTrait:: |
protected | function | Renames the data table to 'entity_test_update_data_new'. | |
EntityDefinitionTestTrait:: |
protected | function | Renames the revision table to 'entity_test_update_revision_new'. | |
EntityDefinitionTestTrait:: |
protected | function | Renames the revision data table to 'entity_test_update_revision_data_new'. | |
EntityDefinitionTestTrait:: |
protected | function | Resets the entity type definition. | |
EntityDefinitionTestTrait:: |
protected | function | Updates the 'entity_test_update' entity type not revisionable. | |
EntityDefinitionTestTrait:: |
protected | function | Updates the 'entity_test_update' entity type to not translatable. | |
EntityDefinitionTestTrait:: |
protected | function | Updates the 'entity_test_update' entity type to revisionable. | |
EntityDefinitionTestTrait:: |
protected | function | Updates the 'entity_test_update' entity type to revisionable and translatable. | |
EntityDefinitionTestTrait:: |
protected | function | Updates the 'entity_test_update' entity type to translatable. | |
EntityKernelTestBase:: |
protected | property | The entity type manager service. | 1 |
EntityKernelTestBase:: |
protected | property | A list of generated identifiers. | |
EntityKernelTestBase:: |
protected | property | The state service. | |
EntityKernelTestBase:: |
protected | function | Creates a user. | |
EntityKernelTestBase:: |
protected | function | Generates a random ID avoiding collisions. | |
EntityKernelTestBase:: |
protected | function | Returns the entity_test hook invocation info. | |
EntityKernelTestBase:: |
protected | function | Installs a module and refreshes services. | |
EntityKernelTestBase:: |
protected | function | Reloads the given entity from the storage and returns it. | |
EntityKernelTestBase:: |
protected | function | Uninstalls a module and refreshes services. | |
EntitySchemaTest:: |
protected | property | The database connection used. | |
EntitySchemaTest:: |
protected static | property |
Modules to enable. Overrides EntityKernelTestBase:: |
|
EntitySchemaTest:: |
protected | function | Finds the primary keys for a given entity type. | |
EntitySchemaTest:: |
public | function | Provides test cases for EntitySchemaTest::testPrimaryKeyUpdate() | |
EntitySchemaTest:: |
protected | function |
Refresh services. Overrides EntityKernelTestBase:: |
|
EntitySchemaTest:: |
protected | function |
Overrides EntityKernelTestBase:: |
|
EntitySchemaTest:: |
public | function | Tests fields from an uninstalled module are removed from the schema. | |
EntitySchemaTest:: |
public | function | Tests the custom bundle field creation and deletion. | |
EntitySchemaTest:: |
public | function | Tests that entity schema responds to changes in the entity type definition. | |
EntitySchemaTest:: |
public | function | Tests the installed storage schema for identifier fields. | |
EntitySchemaTest:: |
public | function | Tests that modifying the UUID field for a translatable entity works. | |
EntitySchemaTest:: |
public | function | Tests deleting and creating a field that is part of a primary key. | |
EntitySchemaTest:: |
protected | function | Updates the entity type definition. | |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified module. | |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified theme. | |
KernelTestBase:: |
protected | property | Back up and restore any global variables that may be changed by tests. | |
KernelTestBase:: |
protected | property | Back up and restore static class properties that may be changed by tests. | |
KernelTestBase:: |
protected | property | Contains a few static class properties for performance. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | @todo Move into Config test base class. | 7 |
KernelTestBase:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. | |
KernelTestBase:: |
protected | property | The app root. | |
KernelTestBase:: |
protected | property | Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Set to TRUE to strict check all configuration saved. | 6 |
KernelTestBase:: |
protected | property | The virtual filesystem root directory. | |
KernelTestBase:: |
protected | function | 1 | |
KernelTestBase:: |
protected | function | Bootstraps a basic test environment. | |
KernelTestBase:: |
private | function | Bootstraps a kernel for a test. | |
KernelTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
KernelTestBase:: |
protected | function | Disables modules for this test. | |
KernelTestBase:: |
protected | function | Enables modules for this test. | |
KernelTestBase:: |
protected | function | Gets the config schema exclusions for this test. | |
KernelTestBase:: |
protected | function | Returns the Database connection info to be used for this test. | 3 |
KernelTestBase:: |
public | function | ||
KernelTestBase:: |
private | function | Returns Extension objects for $modules to enable. | |
KernelTestBase:: |
private static | function | Returns the modules to enable for this test. | |
KernelTestBase:: |
protected | function | Initializes the FileCache component. | |
KernelTestBase:: |
protected | function | Installs default configuration for a given list of modules. | |
KernelTestBase:: |
protected | function | Installs the storage schema for a specific entity type. | |
KernelTestBase:: |
protected | function | Installs database tables from a module schema definition. | |
KernelTestBase:: |
protected | function | ||
KernelTestBase:: |
public | function |
Registers test-specific services. Overrides ServiceProviderInterface:: |
24 |
KernelTestBase:: |
protected | function | Renders a render array. | 1 |
KernelTestBase:: |
protected | function | Sets the install profile and rebuilds the container to update it. | |
KernelTestBase:: |
protected | function | Sets an in-memory Settings variable. | |
KernelTestBase:: |
public static | function | 1 | |
KernelTestBase:: |
protected | function | Sets up the filesystem, so things like the file directory. | 2 |
KernelTestBase:: |
protected | function | Stops test execution. | |
KernelTestBase:: |
protected | function | 4 | |
KernelTestBase:: |
public | function | @after | |
KernelTestBase:: |
protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |
KernelTestBase:: |
public | function | Prevents serializing any properties. | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. Aliased as: drupalCheckPermissions | |
UserCreationTrait:: |
protected | function | Creates an administrative role. Aliased as: drupalCreateAdminRole | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. Aliased as: drupalCreateRole | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. Aliased as: drupalCreateUser | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. Aliased as: drupalGrantPermissions | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. Aliased as: drupalSetCurrentUser | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. Aliased as: drupalSetUpCurrentUser |