function FieldStorageCrudTest::testUpdateFieldType

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php \Drupal\Tests\field\Kernel\FieldStorageCrudTest::testUpdateFieldType()
  2. 10 core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php \Drupal\Tests\field\Kernel\FieldStorageCrudTest::testUpdateFieldType()
  3. 11.x core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php \Drupal\Tests\field\Kernel\FieldStorageCrudTest::testUpdateFieldType()

File

core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php, line 370

Class

FieldStorageCrudTest
Tests field storage create, read, update, and delete.

Namespace

Drupal\Tests\field\Kernel

Code

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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.