function EntityContextDefinitionIsSatisfiedTest::testIsSatisfiedBy

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php \Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::testIsSatisfiedBy()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php \Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::testIsSatisfiedBy()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php \Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::testIsSatisfiedBy()

@covers ::isSatisfiedBy
@covers ::dataTypeMatches
@covers ::getSampleValues
@covers ::getConstraintObjects

@dataProvider providerTestIsSatisfiedBy

File

core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php, line 111

Class

EntityContextDefinitionIsSatisfiedTest
@coversDefaultClass \Drupal\Core\Plugin\Context\EntityContextDefinition[[api-linebreak]] @group Plugin

Namespace

Drupal\Tests\Core\Plugin\Context

Code

public function testIsSatisfiedBy($expected, ContextDefinition $requirement, ContextDefinition $definition, $value = NULL) : void {
  $entity_storage = $this->prophesize(EntityStorageInterface::class);
  $content_entity_storage = $this->prophesize(ContentEntityStorageInterface::class);
  $this->entityTypeManager
    ->getStorage('test_config')
    ->willReturn($entity_storage->reveal());
  $this->entityTypeManager
    ->getStorage('test_content')
    ->willReturn($content_entity_storage->reveal());
  $config_entity_type = new EntityType([
    'id' => 'test_config',
  ]);
  $content_entity_type = new EntityType([
    'id' => 'test_content',
  ]);
  $this->entityTypeManager
    ->getDefinition('test_config')
    ->willReturn($config_entity_type);
  $this->entityTypeManager
    ->getDefinition('test_content')
    ->willReturn($content_entity_type);
  $this->entityTypeManager
    ->getDefinitions()
    ->willReturn([
    'test_config' => $config_entity_type,
    'test_content' => $content_entity_type,
  ]);
  $this->entityTypeBundleInfo
    ->getBundleInfo('test_config')
    ->willReturn([
    'test_config' => [
      'label' => 'test_config',
    ],
  ]);
  $this->entityTypeBundleInfo
    ->getBundleInfo('test_content')
    ->willReturn([
    'test_content' => [
      'label' => 'test_content',
    ],
  ]);
  $this->assertRequirementIsSatisfied($expected, $requirement, $definition, $value);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.