diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php index 0cda34a..8152069 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\content_moderation\Kernel; use Drupal\content_moderation\Entity\ContentModerationState; +use Drupal\Core\Entity\EntityPublishedInterface; use Drupal\entity_test\Entity\EntityTestBundle; use Drupal\entity_test\Entity\EntityTestWithBundle; use Drupal\Core\Entity\EntityInterface; @@ -101,11 +102,15 @@ public function testBasicModeration($entity_type_id) { $entity = $this->reloadEntity($entity, 3); $this->assertEquals('draft', $entity->moderation_state->value); - $this->assertFalse($entity->isPublished()); + if ($entity instanceof EntityPublishedInterface) { + $this->assertFalse($entity->isPublished()); + } // Get the default revision. $entity = $this->reloadEntity($entity); - $this->assertTrue((bool) $entity->isPublished()); + if ($entity instanceof EntityPublishedInterface) { + $this->assertTrue((bool) $entity->isPublished()); + } $this->assertEquals(2, $entity->getRevisionId()); $entity->moderation_state->value = 'published'; @@ -116,7 +121,9 @@ public function testBasicModeration($entity_type_id) { // Get the default revision. $entity = $this->reloadEntity($entity); - $this->assertTrue((bool) $entity->isPublished()); + if ($entity instanceof EntityPublishedInterface) { + $this->assertTrue((bool) $entity->isPublished()); + } $this->assertEquals(4, $entity->getRevisionId()); } diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php index c8b5b84..532fac2 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php @@ -3,8 +3,6 @@ namespace Drupal\entity_test\Entity; use Drupal\Core\Entity\ContentEntityBase; -use Drupal\Core\Entity\EntityPublishedInterface; -use Drupal\Core\Entity\EntityPublishedTrait; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; @@ -47,15 +45,13 @@ * }, * ) */ -class EntityTestWithBundle extends ContentEntityBase implements EntityPublishedInterface { - - use EntityPublishedTrait; +class EntityTestWithBundle extends ContentEntityBase { /** * {@inheritdoc} */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { - $fields = parent::baseFieldDefinitions($entity_type) + static::publishedBaseFieldDefinitions($entity_type); + $fields = parent::baseFieldDefinitions($entity_type); $fields['name'] = BaseFieldDefinition::create('string') ->setLabel(t('Name'))