public function FieldStorageCrudTest::testUpdateFieldType in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php \Drupal\Tests\field\Kernel\FieldStorageCrudTest::testUpdateFieldType()
File
- core/
modules/ field/ tests/ src/ Kernel/ FieldStorageCrudTest.php, line 374
Class
- FieldStorageCrudTest
- Tests field storage create, read, update, and delete.
Namespace
Drupal\Tests\field\KernelCode
public function testUpdateFieldType() {
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_type',
'entity_type' => 'entity_test',
'type' => 'decimal',
]);
$field_storage
->save();
try {
$field_storage
->set('type', 'integer');
$field_storage
->save();
$this
->fail('Cannot update a field to a different type.');
} catch (\Exception $e) {
$this
->assertInstanceOf(FieldException::class, $e);
}
}