Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Plugin / ContextDefinitionTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Plugin;
4
5 use Drupal\Core\Plugin\Context\ContextDefinition;
6 use Drupal\Core\Plugin\Context\EntityContext;
7 use Drupal\entity_test\Entity\EntityTest;
8 use Drupal\KernelTests\KernelTestBase;
9
10 /**
11  * @coversDefaultClass \Drupal\Core\Plugin\Context\ContextDefinition
12  * @group Plugin
13  */
14 class ContextDefinitionTest extends KernelTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['entity_test', 'user'];
20
21   /**
22    * @covers ::isSatisfiedBy
23    */
24   public function testIsSatisfiedBy() {
25     $this->installEntitySchema('user');
26
27     $value = EntityTest::create([]);
28     // Assert that the entity has at least one violation.
29     $this->assertNotEmpty($value->validate());
30     // Assert that these violations do not prevent it from satisfying the
31     // requirements of another object.
32     $requirement = new ContextDefinition('any');
33     $context = EntityContext::fromEntity($value);
34     $this->assertTrue($requirement->isSatisfiedBy($context));
35   }
36
37 }