You are here

public function EntityContextDefinitionIsSatisfiedTest::testIsSatisfiedBy in Drupal 9

Same name and namespace in other branches
  1. 8 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 106

Class

EntityContextDefinitionIsSatisfiedTest
@coversDefaultClass \Drupal\Core\Plugin\Context\EntityContextDefinition @group Plugin

Namespace

Drupal\Tests\Core\Plugin\Context

Code

public function testIsSatisfiedBy($expected, ContextDefinition $requirement, ContextDefinition $definition, $value = NULL) {
  $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);
}