Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Plugin / EntityContextTypedDataTest.php
diff --git a/web/core/tests/Drupal/KernelTests/Core/Plugin/EntityContextTypedDataTest.php b/web/core/tests/Drupal/KernelTests/Core/Plugin/EntityContextTypedDataTest.php
new file mode 100644 (file)
index 0000000..c26a3f8
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Drupal\KernelTests\Core\Plugin;
+
+use Drupal\Core\Entity\Entity\EntityViewDisplay;
+use Drupal\Core\Plugin\Context\EntityContext;
+use Drupal\KernelTests\KernelTestBase;
+
+/**
+ * Tests the interaction between entity context and typed data.
+ *
+ * @group Context
+ */
+class EntityContextTypedDataTest extends KernelTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $modules = ['entity_test'];
+
+  /**
+   * Tests that entity contexts wrapping a config entity can be validated.
+   */
+  public function testValidateConfigEntityContext() {
+    $display = EntityViewDisplay::create([
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+      'status' => TRUE,
+    ]);
+    $display->save();
+
+    $violations = EntityContext::fromEntity($display)->validate();
+    $this->assertCount(0, $violations);
+  }
+
+}