public function SqlContentEntityStorageSchemaColumnTest::setUp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/src/Tests/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php \Drupal\field\Tests\Entity\Update\SqlContentEntityStorageSchemaColumnTest::setUp()
Performs setup tasks before each individual test method is run.
Overrides KernelTestBase::setUp
File
- core/
modules/ field/ src/ Tests/ Entity/ Update/ SqlContentEntityStorageSchemaColumnTest.php, line 52 - Contains \Drupal\field\Tests\Entity\Update\SqlContentEntityStorageSchemaColumnTest.
Class
- SqlContentEntityStorageSchemaColumnTest
- Tests that schema changes in fields with data are detected during updates.
Namespace
Drupal\field\Tests\Entity\UpdateCode
public function setUp() {
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();
}