You are here

public function NodeBodyFieldStorageTest::testFieldOverrides in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/NodeBodyFieldStorageTest.php \Drupal\node\Tests\NodeBodyFieldStorageTest::testFieldOverrides()

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

File

core/modules/node/src/Tests/NodeBodyFieldStorageTest.php, line 43
Contains \Drupal\node\Tests\NodeBodyFieldStorageTest.

Class

NodeBodyFieldStorageTest
Tests node body field storage.

Namespace

Drupal\node\Tests

Code

public function testFieldOverrides() {
  $field_storage = FieldStorageConfig::loadByName('node', 'body');
  $this
    ->assertTrue($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
    ->assertTrue(count($field_storage
    ->getBundles()) == 1, '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
    ->assertTrue(count($field_storage
    ->getBundles()) == 0, 'Node body field storage exists after deleting the only instance of a field.');
  \Drupal::service('module_installer')
    ->uninstall(array(
    'node',
  ));
  $field_storage = FieldStorageConfig::loadByName('node', 'body');
  $this
    ->assertFalse($field_storage, 'Node body field storage does not exist after uninstalling the Node module.');
}