You are here

public function NodeBodyFieldStorageTest::testFieldOverrides in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php \Drupal\Tests\node\Kernel\NodeBodyFieldStorageTest::testFieldOverrides()
  2. 9 core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php \Drupal\Tests\node\Kernel\NodeBodyFieldStorageTest::testFieldOverrides()

Tests node body field storage persistence even if there are no instances.

File

core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php, line 44

Class

NodeBodyFieldStorageTest
Tests node body field storage.

Namespace

Drupal\Tests\node\Kernel

Code

public function testFieldOverrides() {
  $field_storage = FieldStorageConfig::loadByName('node', 'body');
  $this
    ->assertNotEmpty($field_storage, 'Node body field storage exists.');
  $type = NodeType::create([
    'name' => 'Ponies',
    'type' => 'ponies',
  ]);
  $type
    ->save();
  node_add_body_field($type);
  $field_storage = FieldStorageConfig::loadByName('node', 'body');
  $this
    ->assertCount(1, $field_storage
    ->getBundles(), 'Node body field storage is being used on the new node type.');
  $field = FieldConfig::loadByName('node', 'ponies', 'body');
  $field
    ->delete();
  $field_storage = FieldStorageConfig::loadByName('node', 'body');
  $this
    ->assertCount(0, $field_storage
    ->getBundles(), 'Node body field storage exists after deleting the only instance of a field.');
  \Drupal::service('module_installer')
    ->uninstall([
    'node',
  ]);
  $field_storage = FieldStorageConfig::loadByName('node', 'body');
  $this
    ->assertNull($field_storage, 'Node body field storage does not exist after uninstalling the Node module.');
}