function EntityTypeInfoTest::testBaseFieldOnlyAddedToModeratedEntityTypes

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Kernel/EntityTypeInfoTest.php \Drupal\Tests\content_moderation\Kernel\EntityTypeInfoTest::testBaseFieldOnlyAddedToModeratedEntityTypes()
  2. 10 core/modules/content_moderation/tests/src/Kernel/EntityTypeInfoTest.php \Drupal\Tests\content_moderation\Kernel\EntityTypeInfoTest::testBaseFieldOnlyAddedToModeratedEntityTypes()
  3. 11.x core/modules/content_moderation/tests/src/Kernel/EntityTypeInfoTest.php \Drupal\Tests\content_moderation\Kernel\EntityTypeInfoTest::testBaseFieldOnlyAddedToModeratedEntityTypes()

@covers ::entityBaseFieldInfo

File

core/modules/content_moderation/tests/src/Kernel/EntityTypeInfoTest.php, line 113

Class

EntityTypeInfoTest
@coversDefaultClass \Drupal\content_moderation\EntityTypeInfo

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testBaseFieldOnlyAddedToModeratedEntityTypes() {
    $definition = $this->entityTypeManager
        ->getDefinition('entity_test_with_bundle');
    EntityTestBundle::create([
        'id' => 'moderated',
    ])->save();
    EntityTestBundle::create([
        'id' => 'unmoderated',
    ])->save();
    $base_fields = $this->entityTypeInfo
        ->entityBaseFieldInfo($definition);
    $this->assertFalse(isset($base_fields['moderation_state']));
    $this->enableModeration('entity_test_with_bundle', 'moderated');
    $base_fields = $this->entityTypeInfo
        ->entityBaseFieldInfo($definition);
    $this->assertTrue(isset($base_fields['moderation_state']));
}

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