class FieldSqlStorageTest in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php \Drupal\KernelTests\Core\Entity\FieldSqlStorageTest
Tests Field SQL Storage .
Field_sql_storage.module implements the default back-end storage plugin for the Field Storage API.
@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\FieldSqlStorageTest
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses UserCreationTrait
Expanded class hierarchy of FieldSqlStorageTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ FieldSqlStorageTest.php, line 18
Namespace
Drupal\KernelTests\Core\EntityView source
class FieldSqlStorageTest extends EntityKernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'field',
'field_test',
'text',
'entity_test',
];
/**
* The name of the created field.
*
* @var string
*/
protected $fieldName;
/**
* @var int
*/
protected $fieldCardinality;
/**
* A field storage to use in this class.
*
* @var \Drupal\field\Entity\FieldStorageConfig
*/
protected $fieldStorage;
/**
* A field to use in this test class.
*
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* Name of the data table of the field.
*
* @var string
*/
protected $table;
/**
* Name of the revision table of the field.
*
* @var string
*/
protected $revisionTable;
/**
* The table mapping for the tested entity type.
*
* @var \Drupal\Core\Entity\Sql\DefaultTableMapping
*/
protected $tableMapping;
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('entity_test_rev');
$entity_type = 'entity_test_rev';
$this->fieldName = strtolower($this
->randomMachineName());
$this->fieldCardinality = 4;
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $entity_type,
'type' => 'test_field',
'cardinality' => $this->fieldCardinality,
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => $entity_type,
]);
$this->field
->save();
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = \Drupal::entityTypeManager()
->getStorage($entity_type)
->getTableMapping();
$this->tableMapping = $table_mapping;
$this->table = $table_mapping
->getDedicatedDataTableName($this->fieldStorage);
$this->revisionTable = $table_mapping
->getDedicatedRevisionTableName($this->fieldStorage);
}
/**
* Tests field loading works correctly by inserting directly in the tables.
*/
public function testFieldLoad() {
$entity_type = $bundle = 'entity_test_rev';
$storage = $this->container
->get('entity_type.manager')
->getStorage($entity_type);
$columns = [
'bundle',
'deleted',
'entity_id',
'revision_id',
'delta',
'langcode',
$this->tableMapping
->getFieldColumnName($this->fieldStorage, 'value'),
];
// Create an entity with four revisions.
$revision_ids = [];
$entity = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create();
$entity
->save();
$revision_ids[] = $entity
->getRevisionId();
for ($i = 0; $i < 4; $i++) {
$entity
->setNewRevision();
$entity
->save();
$revision_ids[] = $entity
->getRevisionId();
}
// Generate values and insert them directly in the storage tables.
$values = [];
$connection = Database::getConnection();
$query = $connection
->insert($this->revisionTable)
->fields($columns);
foreach ($revision_ids as $revision_id) {
// Put one value too many.
for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) {
$value = mt_rand(1, 127);
$values[$revision_id][] = $value;
$query
->values([
$bundle,
0,
$entity
->id(),
$revision_id,
$delta,
$entity
->language()
->getId(),
$value,
]);
}
$query
->execute();
}
$query = $connection
->insert($this->table)
->fields($columns);
foreach ($values[$revision_id] as $delta => $value) {
$query
->values([
$bundle,
0,
$entity
->id(),
$revision_id,
$delta,
$entity
->language()
->getId(),
$value,
]);
}
$query
->execute();
// Load every revision and check the values.
foreach ($revision_ids as $revision_id) {
$entity = $storage
->loadRevision($revision_id);
foreach ($values[$revision_id] as $delta => $value) {
if ($delta < $this->fieldCardinality) {
$this
->assertEquals($value, $entity->{$this->fieldName}[$delta]->value);
}
else {
$this
->assertArrayNotHasKey($delta, $entity->{$this->fieldName});
}
}
}
// Load the "current revision" and check the values.
$entity = $storage
->load($entity
->id());
foreach ($values[$revision_id] as $delta => $value) {
if ($delta < $this->fieldCardinality) {
$this
->assertEquals($value, $entity->{$this->fieldName}[$delta]->value);
}
else {
$this
->assertArrayNotHasKey($delta, $entity->{$this->fieldName});
}
}
// Add a translation in an unavailable language code and verify it is not
// loaded.
$unavailable_langcode = 'xx';
$values = [
$bundle,
0,
$entity
->id(),
$entity
->getRevisionId(),
0,
$unavailable_langcode,
mt_rand(1, 127),
];
$connection
->insert($this->table)
->fields($columns)
->values($values)
->execute();
$connection
->insert($this->revisionTable)
->fields($columns)
->values($values)
->execute();
$entity = $storage
->load($entity
->id());
$this
->assertArrayNotHasKey($unavailable_langcode, $entity->{$this->fieldName});
}
/**
* Tests field saving works correctly by reading directly from the tables.
*/
public function testFieldWrite() {
$entity_type = $bundle = 'entity_test_rev';
$entity = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create();
$revision_values = [];
// Check insert. Add one value too many.
$values = [];
for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
}
$entity->{$this->fieldName} = $values;
$entity
->save();
$connection = Database::getConnection();
// Read the tables and check the correct values have been stored.
$rows = $connection
->select($this->table, 't')
->fields('t')
->execute()
->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
$this
->assertCount($this->fieldCardinality, $rows);
foreach ($rows as $delta => $row) {
$expected = [
'bundle' => $bundle,
'deleted' => 0,
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'langcode' => $entity
->language()
->getId(),
'delta' => $delta,
$this->fieldName . '_value' => $values[$delta]['value'],
];
$this
->assertEquals($expected, $row, "Row {$delta} was stored as expected.");
}
// Test update. Add less values and check that the previous values did not
// persist.
$values = [];
for ($delta = 0; $delta <= $this->fieldCardinality - 2; $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
}
$values_count = count($values);
$entity->{$this->fieldName} = $values;
$entity
->save();
$rows = $connection
->select($this->table, 't')
->fields('t')
->execute()
->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
$this
->assertCount($values_count, $rows);
foreach ($rows as $delta => $row) {
$expected = [
'bundle' => $bundle,
'deleted' => 0,
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'langcode' => $entity
->language()
->getId(),
'delta' => $delta,
$this->fieldName . '_value' => $values[$delta]['value'],
];
$this
->assertEquals($expected, $row, "Row {$delta} was stored as expected.");
}
// Create a new revision.
$revision_values[$entity
->getRevisionId()] = $values;
$values = [];
for ($delta = 0; $delta < $this->fieldCardinality; $delta++) {
$values[$delta]['value'] = mt_rand(1, 127);
}
$entity->{$this->fieldName} = $values;
$entity
->setNewRevision();
$entity
->save();
$revision_values[$entity
->getRevisionId()] = $values;
// Check that data for both revisions are in the revision table.
foreach ($revision_values as $revision_id => $values) {
$rows = $connection
->select($this->revisionTable, 't')
->fields('t')
->condition('revision_id', $revision_id)
->execute()
->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
$this
->assertCount(min(count($values), $this->fieldCardinality), $rows);
foreach ($rows as $delta => $row) {
$expected = [
'bundle' => $bundle,
'deleted' => 0,
'entity_id' => $entity
->id(),
'revision_id' => $revision_id,
'langcode' => $entity
->language()
->getId(),
'delta' => $delta,
$this->fieldName . '_value' => $values[$delta]['value'],
];
$this
->assertEquals($expected, $row, "Row {$delta} was stored as expected.");
}
}
// Test emptying the field.
$entity->{$this->fieldName} = NULL;
$entity
->save();
$rows = $connection
->select($this->table, 't')
->fields('t')
->execute()
->fetchAllAssoc('delta', \PDO::FETCH_ASSOC);
$this
->assertCount(0, $rows);
}
/**
* Tests that long entity type and field names do not break.
*/
public function testLongNames() {
// Use one of the longest entity_type names in core.
$entity_type = $bundle = 'entity_test_multivalue_basefield';
$this
->installEntitySchema('entity_test_multivalue_basefield');
$storage = $this->container
->get('entity_type.manager')
->getStorage($entity_type);
// Create two fields and generate random values.
$name_base = mb_strtolower($this
->randomMachineName(FieldStorageConfig::NAME_MAX_LENGTH - 1));
$field_names = [];
$values = [];
for ($i = 0; $i < 2; $i++) {
$field_names[$i] = $name_base . $i;
FieldStorageConfig::create([
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
'type' => 'test_field',
])
->save();
FieldConfig::create([
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
'bundle' => $bundle,
])
->save();
$values[$field_names[$i]] = mt_rand(1, 127);
}
// Save an entity with values.
$entity = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create($values);
$entity
->save();
// Load the entity back and check the values.
$entity = $storage
->load($entity
->id());
foreach ($field_names as $field_name) {
$this
->assertEquals($values[$field_name], $entity
->get($field_name)->value);
}
}
/**
* Tests trying to update a field with data.
*/
public function testUpdateFieldSchemaWithData() {
$entity_type = 'entity_test_rev';
// Create a decimal 5.2 field and add some data.
$field_storage = FieldStorageConfig::create([
'field_name' => 'decimal52',
'entity_type' => $entity_type,
'type' => 'decimal',
'settings' => [
'precision' => 5,
'scale' => 2,
],
]);
$field_storage
->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $entity_type,
]);
$field
->save();
$entity = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create([
'id' => 0,
'revision_id' => 0,
]);
$entity->decimal52->value = '1.235';
$entity
->save();
// Attempt to update the field in a way that would work without data.
$field_storage
->setSetting('scale', 3);
$this
->expectException(FieldStorageDefinitionUpdateForbiddenException::class);
$field_storage
->save();
}
/**
* Tests that failure to create fields is handled gracefully.
*/
public function testFieldUpdateFailure() {
// Create a text field.
$field_storage = FieldStorageConfig::create([
'field_name' => 'test_text',
'entity_type' => 'entity_test_rev',
'type' => 'text',
'settings' => [
'max_length' => 255,
],
]);
$field_storage
->save();
// Attempt to update the field in a way that would break the storage. The
// parenthesis suffix is needed because SQLite has *very* relaxed rules for
// data types, so we actually need to provide an invalid SQL syntax in order
// to break it.
// @see https://www.sqlite.org/datatype3.html
$prior_field_storage = $field_storage;
$field_storage
->setSetting('max_length', '-1)');
try {
$field_storage
->save();
$this
->fail('Update succeeded.');
} catch (\Exception $e) {
// Expected exception; just continue testing.
}
// Ensure that the field tables are still there.
$tables = [
$this->tableMapping
->getDedicatedDataTableName($prior_field_storage),
$this->tableMapping
->getDedicatedRevisionTableName($prior_field_storage),
];
$schema = Database::getConnection()
->schema();
foreach ($tables as $table_name) {
$this
->assertTrue($schema
->tableExists($table_name), 'Table $table_name exists.');
}
}
/**
* Tests adding and removing indexes while data is present.
*/
public function testFieldUpdateIndexesWithData() {
// Create a decimal field.
$field_name = 'testfield';
$entity_type = 'entity_test_rev';
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'type' => 'text',
]);
$field_storage
->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $entity_type,
]);
$field
->save();
$tables = [
$this->tableMapping
->getDedicatedDataTableName($field_storage),
$this->tableMapping
->getDedicatedRevisionTableName($field_storage),
];
// Verify the indexes we will create do not exist yet.
foreach ($tables as $table) {
$this
->assertFalse(Database::getConnection()
->schema()
->indexExists($table, 'value'), 'No index named value exists in $table');
$this
->assertFalse(Database::getConnection()
->schema()
->indexExists($table, 'value_format'), 'No index named value_format exists in $table');
}
// Add data so the table cannot be dropped.
$entity = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create([
'id' => 1,
'revision_id' => 1,
]);
$entity->{$field_name}->value = 'field data';
$entity
->enforceIsNew();
$entity
->save();
// Add an index.
$field_storage
->setIndexes([
'value' => [
[
'value',
255,
],
],
]);
$field_storage
->save();
foreach ($tables as $table) {
$this
->assertTrue(Database::getConnection()
->schema()
->indexExists($table, "{$field_name}_value"), "Index on value created in @table", [
'@table' => $table,
]);
}
// Add a different index, removing the existing custom one.
$field_storage
->setIndexes([
'value_format' => [
[
'value',
127,
],
[
'format',
127,
],
],
]);
$field_storage
->save();
foreach ($tables as $table) {
$this
->assertTrue(Database::getConnection()
->schema()
->indexExists($table, "{$field_name}_value_format"), "Index on value_format created in @table", [
'@table' => $table,
]);
$this
->assertFalse(Database::getConnection()
->schema()
->indexExists($table, "{$field_name}_value"), "Index on value removed in @table", [
'@table' => $table,
]);
}
// Verify that the tables were not dropped in the process.
$entity = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->load(1);
$this
->assertEquals('field data', $entity->{$field_name}->value);
}
/**
* Tests foreign key support.
*/
public function testFieldSqlStorageForeignKeys() {
// Create a 'shape' field, with a configurable foreign key (see
// field_test_field_schema()).
$field_name = 'testfield';
$foreign_key_name = 'shape';
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'shape',
'settings' => [
'foreign_key_name' => $foreign_key_name,
],
]);
$field_storage
->save();
// Get the field schema.
$schema = $field_storage
->getSchema();
// Retrieve the field definition and check that the foreign key is in place.
$this
->assertEquals($foreign_key_name, $schema['foreign keys'][$foreign_key_name]['table'], 'Foreign key table name preserved through CRUD');
$this
->assertEquals('id', $schema['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'Foreign key column name preserved through CRUD');
// Update the field settings, it should update the foreign key definition too.
$foreign_key_name = 'color';
$field_storage
->setSetting('foreign_key_name', $foreign_key_name);
$field_storage
->save();
// Reload the field schema after the update.
$schema = $field_storage
->getSchema();
// Check that the foreign key is in place.
$this
->assertEquals($foreign_key_name, $schema['foreign keys'][$foreign_key_name]['table'], 'Foreign key table name modified after update');
$this
->assertEquals('id', $schema['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'Foreign key column name modified after update');
}
/**
* Tests table name generation.
*/
public function testTableNames() {
// Note: we need to test entity types with long names. We therefore use
// fields on imaginary entity types (works as long as we don't actually save
// them), and just check the generated table names.
// Short entity type and field name.
$entity_type = 'short_entity_type';
$field_name = 'short_field_name';
$field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
]);
$expected = 'short_entity_type__short_field_name';
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedDataTableName($field_storage));
$expected = 'short_entity_type_revision__short_field_name';
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedRevisionTableName($field_storage));
// Short entity type, long field name
$entity_type = 'short_entity_type';
$field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz';
$field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
]);
$expected = 'short_entity_type__' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedDataTableName($field_storage));
$expected = 'short_entity_type_r__' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedRevisionTableName($field_storage));
// Long entity type, short field name
$entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz';
$field_name = 'short_field_name';
$field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
]);
$expected = 'long_entity_type_abcdefghijklmno__' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedDataTableName($field_storage));
$expected = 'long_entity_type_abcdefghijklmno_r__' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedRevisionTableName($field_storage));
// Long entity type and field name.
$entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz';
$field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz';
$field_storage = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name,
'type' => 'test_field',
]);
$expected = 'long_entity_type_abcdefghijklmno__' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedDataTableName($field_storage));
$expected = 'long_entity_type_abcdefghijklmno_r__' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedRevisionTableName($field_storage));
// Try creating a second field and check there are no clashes.
$field_storage2 = FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => $field_name . '2',
'type' => 'test_field',
]);
$this
->assertNotEquals($this->tableMapping
->getDedicatedDataTableName($field_storage), $this->tableMapping
->getDedicatedDataTableName($field_storage2));
$this
->assertNotEquals($this->tableMapping
->getDedicatedRevisionTableName($field_storage), $this->tableMapping
->getDedicatedRevisionTableName($field_storage2));
// Deleted field.
$field_storage = FieldStorageConfig::create([
'entity_type' => 'some_entity_type',
'field_name' => 'some_field_name',
'type' => 'test_field',
'deleted' => TRUE,
]);
$expected = 'field_deleted_data_' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedDataTableName($field_storage, TRUE));
$expected = 'field_deleted_revision_' . substr(hash('sha256', $field_storage
->uuid()), 0, 10);
$this
->assertEquals($expected, $this->tableMapping
->getDedicatedRevisionTableName($field_storage, TRUE));
// Check that the table mapping is kept up-to-date in a request where a new
// field storage definition is added. Since the cardinality of the field is
// greater than 1, the table name retrieved from getFieldTableName() should
// be the dedicated table.
$field_storage = FieldStorageConfig::create([
'entity_type' => 'entity_test_rev',
'field_name' => 'some_field_name',
'type' => 'test_field',
'cardinality' => 2,
]);
$field_storage
->save();
$table_mapping = \Drupal::entityTypeManager()
->getStorage('entity_test_rev')
->getTableMapping();
$this
->assertEquals($table_mapping
->getDedicatedDataTableName($field_storage), $table_mapping
->getFieldTableName('some_field_name'));
}
}
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. | |
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 | Refresh services. | 1 |
EntityKernelTestBase:: |
protected | function | Reloads the given entity from the storage and returns it. | |
EntityKernelTestBase:: |
protected | function | Uninstalls a module and refreshes services. | |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified module. | |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified theme. | |
FieldSqlStorageTest:: |
protected | property | A field to use in this test class. | |
FieldSqlStorageTest:: |
protected | property | ||
FieldSqlStorageTest:: |
protected | property | The name of the created field. | |
FieldSqlStorageTest:: |
protected | property | A field storage to use in this class. | |
FieldSqlStorageTest:: |
protected static | property |
Modules to enable. Overrides EntityKernelTestBase:: |
|
FieldSqlStorageTest:: |
protected | property | Name of the revision table of the field. | |
FieldSqlStorageTest:: |
protected | property | Name of the data table of the field. | |
FieldSqlStorageTest:: |
protected | property | The table mapping for the tested entity type. | |
FieldSqlStorageTest:: |
protected | function |
Overrides EntityKernelTestBase:: |
|
FieldSqlStorageTest:: |
public | function | Tests field loading works correctly by inserting directly in the tables. | |
FieldSqlStorageTest:: |
public | function | Tests foreign key support. | |
FieldSqlStorageTest:: |
public | function | Tests that failure to create fields is handled gracefully. | |
FieldSqlStorageTest:: |
public | function | Tests adding and removing indexes while data is present. | |
FieldSqlStorageTest:: |
public | function | Tests field saving works correctly by reading directly from the tables. | |
FieldSqlStorageTest:: |
public | function | Tests that long entity type and field names do not break. | |
FieldSqlStorageTest:: |
public | function | Tests table name generation. | |
FieldSqlStorageTest:: |
public | function | Tests trying to update a field with data. | |
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 |