Issue #2952962 by tim.plunkett, sureshcj, JordiK, Madis, cilefen: Block visibility setting tab for Roles not showing
parent
bc07d425c8
commit
5d5af494fb
|
@ -282,7 +282,14 @@ class ContextDefinition implements ContextDefinitionInterface {
|
|||
|
||||
$validator = $this->getTypedDataManager()->getValidator();
|
||||
foreach ($values as $value) {
|
||||
$violations = $validator->validate($value, array_values($this->getConstraintObjects()));
|
||||
$constraints = array_values($this->getConstraintObjects());
|
||||
$violations = $validator->validate($value, $constraints);
|
||||
foreach ($violations as $delta => $violation) {
|
||||
// Remove any violation that does not correspond to the constraints.
|
||||
if (!in_array($violation->getConstraint(), $constraints)) {
|
||||
$violations->remove($delta);
|
||||
}
|
||||
}
|
||||
// If a value has no violations then the requirement is satisfied.
|
||||
if (!$violations->count()) {
|
||||
return TRUE;
|
||||
|
|
|
@ -0,0 +1,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));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue