function EntityDefinitionUpdateTest::testBaseFieldWithoutLabelCreateUpdateDelete

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testBaseFieldWithoutLabelCreateUpdateDelete()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testBaseFieldWithoutLabelCreateUpdateDelete()
  3. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testBaseFieldWithoutLabelCreateUpdateDelete()

Tests creating, updating, and deleting a base field with no label set.

See testBaseFieldCreateUpdateDeleteWithoutData() for more details

File

core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php, line 337

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testBaseFieldWithoutLabelCreateUpdateDelete() : void {
    // Add a base field, ensure the update manager reports it with the
    // field id.
    $this->addBaseField('string', 'entity_test_update', FALSE, FALSE);
    $changes = $this->entityDefinitionUpdateManager
        ->getChangeSummary();
    $this->assertCount(1, $changes['entity_test_update']);
    $this->assertEquals('The new_base_field field needs to be installed.', strip_tags((string) $changes['entity_test_update'][0]));
    $this->applyEntityUpdates();
    // Add an index on the base field, ensure the update manager reports it with
    // the field id.
    $this->addBaseFieldIndex();
    $changes = $this->entityDefinitionUpdateManager
        ->getChangeSummary();
    $this->assertCount(1, $changes['entity_test_update']);
    $this->assertEquals('The new_base_field field needs to be updated.', strip_tags((string) $changes['entity_test_update'][0]));
    $this->applyEntityUpdates();
    // Remove the base field, ensure the update manager reports it with the
    // field id.
    $this->removeBaseField();
    $changes = $this->entityDefinitionUpdateManager
        ->getChangeSummary();
    $this->assertCount(1, $changes['entity_test_update']);
    $this->assertEquals('The new_base_field field needs to be uninstalled.', strip_tags((string) $changes['entity_test_update'][0]));
}

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