Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Drupal\KernelTests\Core\Plugin;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
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 = new Context(new ContextDefinition('entity:entity_test'), $value);
$this->assertTrue($requirement->isSatisfiedBy($context));
}
}