Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / content_moderation / tests / src / Kernel / EntityTypeInfoTest.php
index a5791c8840bb43a555a3025e6169522d0adff356..09990fe796a8687bfebc530573f47ade429945ca 100644 (file)
@@ -61,4 +61,34 @@ class EntityTypeInfoTest extends KernelTestBase {
     $this->assertTrue($base_fields['moderation_state']->isTranslatable());
   }
 
+  /**
+   * Test the correct entity types have moderation added.
+   *
+   * @covers ::entityTypeAlter
+   *
+   * @dataProvider providerTestEntityTypeAlter
+   */
+  public function testEntityTypeAlter($entity_type_id, $moderatable) {
+    $entity_types = $this->entityTypeManager->getDefinitions();
+    $this->assertSame($moderatable, $entity_types[$entity_type_id]->hasHandlerClass('moderation'));
+  }
+
+  /**
+   * Provides test data for testEntityTypeAlter().
+   *
+   * @return array
+   *   An array of test cases, where each test case is an array with the
+   *   following values:
+   *   - An entity type ID.
+   *   - Whether the entity type is moderatable or not.
+   */
+  public function providerTestEntityTypeAlter() {
+    $tests = [];
+    $tests['non_internal_non_revisionable'] = ['entity_test', FALSE];
+    $tests['non_internal_revisionable'] = ['entity_test_rev', TRUE];
+    $tests['internal_non_revisionable'] = ['entity_test_no_label', FALSE];
+    $tests['internal_revisionable'] = ['content_moderation_state', FALSE];
+    return $tests;
+  }
+
 }