Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Plugin / ContextDefinitionTest.php
diff --git a/web/core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php b/web/core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php
new file mode 100644 (file)
index 0000000..842f76b
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Drupal\KernelTests\Core\Plugin;
+
+use Drupal\Core\Plugin\Context\ContextDefinition;
+use Drupal\Core\Plugin\Context\EntityContext;
+use Drupal\entity_test\Entity\EntityTest;
+use Drupal\KernelTests\KernelTestBase;
+
+/**
+ * @coversDefaultClass \Drupal\Core\Plugin\Context\ContextDefinition
+ * @group Plugin
+ */
+class ContextDefinitionTest extends KernelTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['entity_test', 'user'];
+
+  /**
+   * @covers ::isSatisfiedBy
+   */
+  public function testIsSatisfiedBy() {
+    $this->installEntitySchema('user');
+
+    $value = EntityTest::create([]);
+    // Assert that the entity has at least one violation.
+    $this->assertNotEmpty($value->validate());
+    // Assert that these violations do not prevent it from satisfying the
+    // requirements of another object.
+    $requirement = new ContextDefinition('any');
+    $context = EntityContext::fromEntity($value);
+    $this->assertTrue($requirement->isSatisfiedBy($context));
+  }
+
+}