public function FieldDeletionTest::testDeleteFieldDuringSync in Tome 8
@covers \Drupal\tome_sync\Exporter::exportContent
File
- modules/
tome_sync/ tests/ src/ Kernel/ FieldDeletionTest.php, line 78
Class
- FieldDeletionTest
- Tests that exports are updated when fields are deleted.
Namespace
Drupal\Tests\tome_sync\KernelCode
public function testDeleteFieldDuringSync() {
/** @var \Drupal\Core\Config\StorageInterface $storage */
$storage = \Drupal::service('tome_sync.storage.content');
$field_config = node_add_body_field(NodeType::load('article'));
node_add_body_field(NodeType::load('page'));
$article = Node::create([
'type' => 'article',
'title' => 'My article',
]);
$article
->save();
$data = $storage
->read(TomeSyncHelper::getContentName($article));
$this
->assertArrayHasKey('body', $data);
/** @var \Drupal\Core\Config\ConfigInstallerInterface $installer */
$installer = \Drupal::service('config.installer');
$installer
->setSyncing(TRUE);
$field_config
->delete();
$installer
->setSyncing(FALSE);
$data = $storage
->read(TomeSyncHelper::getContentName($article));
$this
->assertArrayHasKey('body', $data);
}