class NodeBodyFieldStorageTest
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php \Drupal\Tests\node\Kernel\NodeBodyFieldStorageTest
- 10 core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php \Drupal\Tests\node\Kernel\NodeBodyFieldStorageTest
- 8.9.x core/modules/node/tests/src/Kernel/NodeBodyFieldStorageTest.php \Drupal\Tests\node\Kernel\NodeBodyFieldStorageTest
Tests node body field storage.
@group node
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\node\Kernel\NodeBodyFieldStorageTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of NodeBodyFieldStorageTest
File
-
core/
modules/ node/ tests/ src/ Kernel/ NodeBodyFieldStorageTest.php, line 15
Namespace
Drupal\Tests\node\KernelView source
class NodeBodyFieldStorageTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'user',
'system',
'field',
'node',
'text',
'filter',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installSchema('system', 'sequences');
// Necessary for module uninstall.
$this->installSchema('user', 'users_data');
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installConfig([
'field',
'node',
]);
}
/**
* Tests node body field storage persistence even if there are no instances.
*/
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.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.