class EntitySchemaTest
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php \Drupal\KernelTests\Core\Entity\EntitySchemaTest
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php \Drupal\KernelTests\Core\Entity\EntitySchemaTest
- 11.x 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 \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\AssertHelperTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpunitCompatibilityTrait
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait
- class \Drupal\KernelTests\Core\Entity\EntitySchemaTest extends \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait
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
*/
public static $modules = [
'entity_test_update',
];
/**
* The database connection used.
*
* @var \Drupal\Core\Database\Connection
*/
protected $database;
/**
* {@inheritdoc}
*/
protected function setUp() {
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->assertEqual($schema_handler->tableExists($table), !$index, 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->assertEqual($schema_handler->tableExists($table), !$index, 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);
// The schema of ID fields is incorrectly recreated as 'int' instead of
// 'serial', so we manually have to specify an ID.
// @todo Remove this in https://www.drupal.org/project/drupal/issues/2928906
$storage->create([
'id' => 1,
'revision_id' => 1,
])
->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->assertNotEqual($entity_type_id_count, 0, '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->assertEqual($entity_type_id_count, 0, '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
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Member alias | Overriden Title | Overrides |
---|---|---|---|---|---|---|---|
AssertContentTrait::$content | protected | property | The current raw content. | ||||
AssertContentTrait::$drupalSettings | protected | property | The drupalSettings value from the current raw $content. | ||||
AssertContentTrait::$elements | protected | property | The XML structure parsed from the current raw $content. | 1 | |||
AssertContentTrait::$plainTextContent | protected | property | The plain-text content of raw $content (text nodes). | ||||
AssertContentTrait::assertEscaped | protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | ||||
AssertContentTrait::assertField | protected | function | Asserts that a field exists with the given name or ID. | ||||
AssertContentTrait::assertFieldById | protected | function | Asserts that a field exists with the given ID and value. | ||||
AssertContentTrait::assertFieldByName | protected | function | Asserts that a field exists with the given name and value. | ||||
AssertContentTrait::assertFieldByXPath | protected | function | Asserts that a field exists in the current page by the given XPath. | ||||
AssertContentTrait::assertFieldChecked | protected | function | Asserts that a checkbox field in the current page is checked. | ||||
AssertContentTrait::assertFieldsByValue | protected | function | Asserts that a field exists in the current page with a given Xpath result. | ||||
AssertContentTrait::assertLink | protected | function | Passes if a link with the specified label is found. | ||||
AssertContentTrait::assertLinkByHref | protected | function | Passes if a link containing a given href (part) is found. | ||||
AssertContentTrait::assertNoDuplicateIds | protected | function | Asserts that each HTML ID is used for just a single element. | ||||
AssertContentTrait::assertNoEscaped | protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. |
||||
AssertContentTrait::assertNoField | protected | function | Asserts that a field does not exist with the given name or ID. | ||||
AssertContentTrait::assertNoFieldById | protected | function | Asserts that a field does not exist with the given ID and value. | ||||
AssertContentTrait::assertNoFieldByName | protected | function | Asserts that a field does not exist with the given name and value. | ||||
AssertContentTrait::assertNoFieldByXPath | protected | function | Asserts that a field does not exist or its value does not match, by XPath. | ||||
AssertContentTrait::assertNoFieldChecked | protected | function | Asserts that a checkbox field in the current page is not checked. | ||||
AssertContentTrait::assertNoLink | protected | function | Passes if a link with the specified label is not found. | ||||
AssertContentTrait::assertNoLinkByHref | protected | function | Passes if a link containing a given href (part) is not found. | ||||
AssertContentTrait::assertNoLinkByHrefInMainRegion | protected | function | Passes if a link containing a given href is not found in the main region. | ||||
AssertContentTrait::assertNoOption | protected | function | Asserts that a select option in the current page does not exist. | ||||
AssertContentTrait::assertNoOptionSelected | protected | function | Asserts that a select option in the current page is not checked. | ||||
AssertContentTrait::assertNoPattern | protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | ||||
AssertContentTrait::assertNoRaw | protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | ||||
AssertContentTrait::assertNoText | protected | function | Passes if the page (with HTML stripped) does not contains the text. | ||||
AssertContentTrait::assertNoTitle | protected | function | Pass if the page title is not the given string. | ||||
AssertContentTrait::assertNoUniqueText | protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | ||||
AssertContentTrait::assertOption | protected | function | Asserts that a select option in the current page exists. | ||||
AssertContentTrait::assertOptionByText | protected | function | Asserts that a select option with the visible text exists. | ||||
AssertContentTrait::assertOptionSelected | protected | function | Asserts that a select option in the current page is checked. | ||||
AssertContentTrait::assertOptionSelectedWithDrupalSelector | protected | function | Asserts that a select option in the current page is checked. | ||||
AssertContentTrait::assertOptionWithDrupalSelector | protected | function | Asserts that a select option in the current page exists. | ||||
AssertContentTrait::assertPattern | protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | ||||
AssertContentTrait::assertRaw | protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | ||||
AssertContentTrait::assertText | protected | function | Passes if the page (with HTML stripped) contains the text. | ||||
AssertContentTrait::assertTextHelper | protected | function | Helper for assertText and assertNoText. | ||||
AssertContentTrait::assertTextPattern | protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | ||||
AssertContentTrait::assertThemeOutput | protected | function | Asserts themed output. | ||||
AssertContentTrait::assertTitle | protected | function | Pass if the page title is the given string. | ||||
AssertContentTrait::assertUniqueText | protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | ||||
AssertContentTrait::assertUniqueTextHelper | protected | function | Helper for assertUniqueText and assertNoUniqueText. | ||||
AssertContentTrait::buildXPathQuery | protected | function | Builds an XPath query. | ||||
AssertContentTrait::constructFieldXpath | protected | function | Helper: Constructs an XPath for the given set of attributes and value. | ||||
AssertContentTrait::cssSelect | protected | function | Searches elements using a CSS selector in the raw content. | ||||
AssertContentTrait::getAllOptions | protected | function | Get all option elements, including nested options, in a select. | ||||
AssertContentTrait::getDrupalSettings | protected | function | Gets the value of drupalSettings for the currently-loaded page. | ||||
AssertContentTrait::getRawContent | protected | function | Gets the current raw content. | ||||
AssertContentTrait::getSelectedItem | protected | function | Get the selected value from a select field. | ||||
AssertContentTrait::getTextContent | protected | function | Retrieves the plain-text content from the current raw content. | ||||
AssertContentTrait::getUrl | protected | function | Get the current URL from the cURL handler. | 1 | |||
AssertContentTrait::parse | protected | function | Parse content returned from curlExec using DOM and SimpleXML. | ||||
AssertContentTrait::removeWhiteSpace | protected | function | Removes all white-space between HTML tags from the raw content. | ||||
AssertContentTrait::setDrupalSettings | protected | function | Sets the value of drupalSettings for the currently-loaded page. | ||||
AssertContentTrait::setRawContent | protected | function | Sets the raw content (e.g. HTML). | ||||
AssertContentTrait::xpath | protected | function | Performs an xpath search on the contents of the internal browser. | ||||
AssertHelperTrait::castSafeStrings | protected static | function | Casts MarkupInterface objects into strings. | ||||
AssertLegacyTrait::assert | protected | function | |||||
AssertLegacyTrait::assertEqual | protected | function | |||||
AssertLegacyTrait::assertIdentical | protected | function | |||||
AssertLegacyTrait::assertIdenticalObject | protected | function | |||||
AssertLegacyTrait::assertNotEqual | protected | function | |||||
AssertLegacyTrait::assertNotIdentical | protected | function | |||||
AssertLegacyTrait::pass | protected | function | |||||
AssertLegacyTrait::verbose | protected | function | |||||
ConfigTestTrait::configImporter | protected | function | Returns a ConfigImporter object to import test configuration. | ||||
ConfigTestTrait::copyConfig | protected | function | Copies configuration objects from source storage to target storage. | ||||
DeprecatedServicePropertyTrait::__get | public | function | Allows to access deprecated/removed properties. | ||||
EntityDefinitionTestTrait::addBaseField | protected | function | Adds a new base field to the 'entity_test_update' entity type. | ||||
EntityDefinitionTestTrait::addBaseFieldIndex | protected | function | Adds a single-field index to the base field. | ||||
EntityDefinitionTestTrait::addBundleField | protected | function | Adds a new bundle field to the 'entity_test_update' entity type. | ||||
EntityDefinitionTestTrait::addEntityIndex | protected | function | Adds an index to the 'entity_test_update' entity type's base table. | ||||
EntityDefinitionTestTrait::addLongNameBaseField | protected | function | Adds a long-named base field to the 'entity_test_update' entity type. | ||||
EntityDefinitionTestTrait::addRevisionableBaseField | protected | function | Adds a new revisionable base field to the 'entity_test_update' entity type. | ||||
EntityDefinitionTestTrait::applyEntityUpdates | protected | function | Applies all the detected valid changes. | ||||
EntityDefinitionTestTrait::deleteEntityType | protected | function | Removes the entity type. | ||||
EntityDefinitionTestTrait::doEntityUpdate | protected | function | Performs an entity type definition update. | ||||
EntityDefinitionTestTrait::doFieldUpdate | protected | function | Performs a field storage definition update. | ||||
EntityDefinitionTestTrait::enableNewEntityType | protected | function | Enables a new entity type definition. | ||||
EntityDefinitionTestTrait::getUpdatedEntityTypeDefinition | protected | function | Returns an entity type definition, possibly updated to be rev or mul. | ||||
EntityDefinitionTestTrait::getUpdatedFieldStorageDefinitions | protected | function | Returns the required rev / mul field definitions for an entity type. | ||||
EntityDefinitionTestTrait::makeBaseFieldEntityKey | protected | function | Promotes a field to an entity key. | ||||
EntityDefinitionTestTrait::modifyBaseField | protected | function | Modifies the new base field from 'string' to 'text'. | ||||
EntityDefinitionTestTrait::modifyBundleField | protected | function | Modifies the new bundle field from 'string' to 'text'. | ||||
EntityDefinitionTestTrait::removeBaseField | protected | function | Removes the new base field from the 'entity_test_update' entity type. | ||||
EntityDefinitionTestTrait::removeBaseFieldIndex | protected | function | Removes the index added in addBaseFieldIndex(). | ||||
EntityDefinitionTestTrait::removeBundleField | protected | function | Removes the new bundle field from the 'entity_test_update' entity type. | ||||
EntityDefinitionTestTrait::removeEntityIndex | protected | function | Removes the index added in addEntityIndex(). | ||||
EntityDefinitionTestTrait::renameBaseTable | protected | function | Renames the base table to 'entity_test_update_new'. | ||||
EntityDefinitionTestTrait::renameDataTable | protected | function | Renames the data table to 'entity_test_update_data_new'. | ||||
EntityDefinitionTestTrait::renameRevisionBaseTable | protected | function | Renames the revision table to 'entity_test_update_revision_new'. | ||||
EntityDefinitionTestTrait::renameRevisionDataTable | protected | function | Renames the revision data table to 'entity_test_update_revision_data_new'. | ||||
EntityDefinitionTestTrait::resetEntityType | protected | function | Resets the entity type definition. | ||||
EntityDefinitionTestTrait::updateEntityTypeToNotRevisionable | protected | function | Updates the 'entity_test_update' entity type not revisionable. | ||||
EntityDefinitionTestTrait::updateEntityTypeToNotTranslatable | protected | function | Updates the 'entity_test_update' entity type to not translatable. | ||||
EntityDefinitionTestTrait::updateEntityTypeToRevisionable | protected | function | Updates the 'entity_test_update' entity type to revisionable. | ||||
EntityDefinitionTestTrait::updateEntityTypeToRevisionableAndTranslatable | protected | function | Updates the 'entity_test_update' entity type to revisionable and translatable. |
||||
EntityDefinitionTestTrait::updateEntityTypeToTranslatable | protected | function | Updates the 'entity_test_update' entity type to translatable. | ||||
EntityKernelTestBase::$deprecatedProperties | protected | property | The list of deprecated services. | ||||
EntityKernelTestBase::$entityTypeManager | protected | property | The entity type manager service. | 1 | |||
EntityKernelTestBase::$generatedIds | protected | property | A list of generated identifiers. | ||||
EntityKernelTestBase::$state | protected | property | The state service. | ||||
EntityKernelTestBase::createUser | protected | function | Creates a user. | ||||
EntityKernelTestBase::generateRandomEntityId | protected | function | Generates a random ID avoiding collisions. | ||||
EntityKernelTestBase::getHooksInfo | protected | function | Returns the entity_test hook invocation info. | ||||
EntityKernelTestBase::installModule | protected | function | Installs a module and refreshes services. | ||||
EntityKernelTestBase::reloadEntity | protected | function | Reloads the given entity from the storage and returns it. | ||||
EntityKernelTestBase::uninstallModule | protected | function | Uninstalls a module and refreshes services. | ||||
EntitySchemaTest::$database | protected | property | The database connection used. | ||||
EntitySchemaTest::$modules | public static | property | Modules to enable. | Overrides EntityKernelTestBase::$modules | |||
EntitySchemaTest::findPrimaryKeys | protected | function | Finds the primary keys for a given entity type. | ||||
EntitySchemaTest::providerTestPrimaryKeyUpdate | public | function | Provides test cases for EntitySchemaTest::testPrimaryKeyUpdate() | ||||
EntitySchemaTest::refreshServices | protected | function | Refresh services. | Overrides EntityKernelTestBase::refreshServices | |||
EntitySchemaTest::setUp | protected | function | Overrides EntityKernelTestBase::setUp | ||||
EntitySchemaTest::testCleanUpStorageDefinition | public | function | Tests fields from an uninstalled module are removed from the schema. | ||||
EntitySchemaTest::testCustomFieldCreateDelete | public | function | Tests the custom bundle field creation and deletion. | ||||
EntitySchemaTest::testEntitySchemaUpdate | public | function | Tests that entity schema responds to changes in the entity type definition. | ||||
EntitySchemaTest::testIdentifierSchema | public | function | Tests the installed storage schema for identifier fields. | ||||
EntitySchemaTest::testModifyingTranslatableColumnSchema | public | function | Tests that modifying the UUID field for a translatable entity works. | ||||
EntitySchemaTest::testPrimaryKeyUpdate | public | function | Tests deleting and creating a field that is part of a primary key. | ||||
EntitySchemaTest::updateEntityType | protected | function | Updates the entity type definition. | ||||
KernelTestBase::$backupGlobals | protected | property | Back up and restore any global variables that may be changed by tests. | ||||
KernelTestBase::$backupStaticAttributes | protected | property | Back up and restore static class properties that may be changed by tests. | ||||
KernelTestBase::$backupStaticAttributesBlacklist | protected | property | Contains a few static class properties for performance. | ||||
KernelTestBase::$classLoader | protected | property | |||||
KernelTestBase::$configImporter | protected | property | @todo Move into Config test base class. | 7 | |||
KernelTestBase::$configSchemaCheckerExclusions | protected static | property | An array of config object names that are excluded from schema checking. | ||||
KernelTestBase::$container | protected | property | |||||
KernelTestBase::$databasePrefix | protected | property | |||||
KernelTestBase::$preserveGlobalState | protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. |
||||
KernelTestBase::$root | protected | property | The app root. | ||||
KernelTestBase::$runTestInSeparateProcess | 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::$siteDirectory | protected | property | |||||
KernelTestBase::$strictConfigSchema | protected | property | Set to TRUE to strict check all configuration saved. | 6 | |||
KernelTestBase::$vfsRoot | protected | property | The virtual filesystem root directory. | ||||
KernelTestBase::assertPostConditions | protected | function | 1 | ||||
KernelTestBase::bootEnvironment | protected | function | Bootstraps a basic test environment. | ||||
KernelTestBase::bootKernel | private | function | Bootstraps a kernel for a test. | ||||
KernelTestBase::config | protected | function | Configuration accessor for tests. Returns non-overridden configuration. | ||||
KernelTestBase::disableModules | protected | function | Disables modules for this test. | ||||
KernelTestBase::enableModules | protected | function | Enables modules for this test. | ||||
KernelTestBase::getConfigSchemaExclusions | protected | function | Gets the config schema exclusions for this test. | ||||
KernelTestBase::getDatabaseConnectionInfo | protected | function | Returns the Database connection info to be used for this test. | 1 | |||
KernelTestBase::getDatabasePrefix | public | function | |||||
KernelTestBase::getExtensionsForModules | private | function | Returns Extension objects for $modules to enable. | ||||
KernelTestBase::getModulesToEnable | private static | function | Returns the modules to enable for this test. | ||||
KernelTestBase::initFileCache | protected | function | Initializes the FileCache component. | ||||
KernelTestBase::installConfig | protected | function | Installs default configuration for a given list of modules. | ||||
KernelTestBase::installEntitySchema | protected | function | Installs the storage schema for a specific entity type. | ||||
KernelTestBase::installSchema | protected | function | Installs database tables from a module schema definition. | ||||
KernelTestBase::isTestInIsolation | Deprecated | protected | function | Returns whether the current test method is running in a separate process. | |||
KernelTestBase::prepareTemplate | protected | function | |||||
KernelTestBase::register | public | function | Registers test-specific services. | Overrides ServiceProviderInterface::register | 26 | ||
KernelTestBase::render | protected | function | Renders a render array. | 1 | |||
KernelTestBase::setInstallProfile | protected | function | Sets the install profile and rebuilds the container to update it. | ||||
KernelTestBase::setSetting | protected | function | Sets an in-memory Settings variable. | ||||
KernelTestBase::setUpBeforeClass | public static | function | 1 | ||||
KernelTestBase::setUpFilesystem | protected | function | Sets up the filesystem, so things like the file directory. | 2 | |||
KernelTestBase::stop | protected | function | Stops test execution. | ||||
KernelTestBase::tearDown | protected | function | 5 | ||||
KernelTestBase::tearDownCloseDatabaseConnection | public | function | @after | ||||
KernelTestBase::vfsDump | protected | function | Dumps the current state of the virtual filesystem to STDOUT. | ||||
KernelTestBase::__sleep | public | function | Prevents serializing any properties. | ||||
PhpunitCompatibilityTrait::getMock | Deprecated | public | function | Returns a mock object for the specified class using the available method. | |||
PhpunitCompatibilityTrait::setExpectedException | Deprecated | public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |||
RandomGeneratorTrait::$randomGenerator | protected | property | The random generator. | ||||
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | ||||
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | 1 | |||
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | ||||
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | ||||
RandomGeneratorTrait::randomStringValidate | public | function | Callback for random string validation. | ||||
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. | ||||
TestRequirementsTrait::checkModuleRequirements | private | function | Checks missing module requirements. | ||||
TestRequirementsTrait::checkRequirements | protected | function | Check module requirements for the Drupal use case. | 1 | |||
TestRequirementsTrait::getDrupalRoot | protected static | function | Returns the Drupal root directory. | ||||
UserCreationTrait::checkPermissions | protected | function | Checks whether a given list of permission names is valid. | Aliased as: drupalCheckPermissions | |||
UserCreationTrait::createAdminRole | protected | function | Creates an administrative role. | Aliased as: drupalCreateAdminRole | |||
UserCreationTrait::createRole | protected | function | Creates a role with specified permissions. | Aliased as: drupalCreateRole | |||
UserCreationTrait::createUser | protected | function | Create a user with a given set of permissions. | Aliased as: drupalCreateUser | |||
UserCreationTrait::grantPermissions | protected | function | Grant permissions to a user role. | Aliased as: drupalGrantPermissions | |||
UserCreationTrait::setCurrentUser | protected | function | Switch the current logged in user. | Aliased as: drupalSetCurrentUser | |||
UserCreationTrait::setUpCurrentUser | protected | function | Creates a random user account and sets it as current user. | Aliased as: drupalSetUpCurrentUser |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.