Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / content_moderation / tests / src / Kernel / EntityTypeInfoTest.php
1 <?php
2
3 namespace Drupal\Tests\content_moderation\Kernel;
4
5 use Drupal\content_moderation\Entity\Handler\ModerationHandler;
6 use Drupal\content_moderation\EntityTypeInfo;
7 use Drupal\KernelTests\KernelTestBase;
8
9 /**
10  * @coversDefaultClass \Drupal\content_moderation\EntityTypeInfo
11  *
12  * @group content_moderation
13  */
14 class EntityTypeInfoTest extends KernelTestBase {
15
16   /**
17    * Modules to enable.
18    *
19    * @var array
20    */
21   public static $modules = [
22     'content_moderation',
23     'entity_test',
24   ];
25
26   /**
27    * The entity type manager.
28    *
29    * @var \Drupal\Core\Entity\EntityTypeManagerInterface
30    */
31   protected $entityTypeManager;
32
33   /**
34    * The entity type info class.
35    *
36    * @var \Drupal\content_moderation\EntityTypeInfo
37    */
38   protected $entityTypeInfo;
39
40   /**
41    * {@inheritdoc}
42    */
43   protected function setUp() {
44     parent::setUp();
45     $this->entityTypeInfo = $this->container->get('class_resolver')->getInstanceFromDefinition(EntityTypeInfo::class);
46     $this->entityTypeManager = $this->container->get('entity_type.manager');
47   }
48
49   /**
50    * @covers ::entityBaseFieldInfo
51    */
52   public function testEntityBaseFieldInfo() {
53     $definition = $this->entityTypeManager->getDefinition('entity_test');
54     $definition->setHandlerClass('moderation', ModerationHandler::class);
55
56     $base_fields = $this->entityTypeInfo->entityBaseFieldInfo($definition);
57
58     $this->assertFalse($base_fields['moderation_state']->isReadOnly());
59     $this->assertTrue($base_fields['moderation_state']->isComputed());
60     $this->assertTrue($base_fields['moderation_state']->isTranslatable());
61   }
62
63 }