function SqlContentEntityStorageSchemaColumnTest::setUp
Same name in other branches
- 8.9.x core/modules/field/tests/src/Kernel/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php \Drupal\Tests\field\Kernel\Entity\Update\SqlContentEntityStorageSchemaColumnTest::setUp()
- 10 core/modules/field/tests/src/Kernel/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php \Drupal\Tests\field\Kernel\Entity\Update\SqlContentEntityStorageSchemaColumnTest::setUp()
- 11.x core/modules/field/tests/src/Kernel/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php \Drupal\Tests\field\Kernel\Entity\Update\SqlContentEntityStorageSchemaColumnTest::setUp()
Overrides KernelTestBase::setUp
File
-
core/
modules/ field/ tests/ src/ Kernel/ Entity/ Update/ SqlContentEntityStorageSchemaColumnTest.php, line 64
Class
- SqlContentEntityStorageSchemaColumnTest
- Tests that schema changes in fields with data are detected during updates.
Namespace
Drupal\Tests\field\Kernel\Entity\UpdateCode
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('entity_test_rev');
$this->installEntitySchema('user');
$field_name = 'test';
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test_rev',
'type' => 'string',
'cardinality' => 1,
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test_rev',
'bundle' => 'entity_test_rev',
'required' => TRUE,
]);
$this->field
->save();
// Create an entity with field data.
$this->entity = EntityTestRev::create([
'user_id' => mt_rand(1, 10),
'name' => $this->randomMachineName(),
$field_name => $this->randomString(),
]);
$this->entity
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.