public function EntityContextDefinitionIsSatisfiedTest::providerTestIsSatisfiedBy in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php \Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::providerTestIsSatisfiedBy()
Provides test data for ::testIsSatisfiedBy().
File
- core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ EntityContextDefinitionIsSatisfiedTest.php, line 134
Class
- EntityContextDefinitionIsSatisfiedTest
- @coversDefaultClass \Drupal\Core\Plugin\Context\EntityContextDefinition @group Plugin
Namespace
Drupal\Tests\Core\Plugin\ContextCode
public function providerTestIsSatisfiedBy() {
$data = [];
$content = new EntityType([
'id' => 'test_content',
]);
$config = new EntityType([
'id' => 'test_config',
]);
// Entities without bundles.
$data['content entity, matching type, no value'] = [
TRUE,
EntityContextDefinition::fromEntityType($content),
EntityContextDefinition::fromEntityType($content),
];
$entity = $this
->prophesize(ContentEntityInterface::class)
->willImplement(\IteratorAggregate::class);
$entity
->getIterator()
->willReturn(new \ArrayIterator([]));
$entity
->getCacheContexts()
->willReturn([]);
$entity
->getCacheTags()
->willReturn([]);
$entity
->getCacheMaxAge()
->willReturn(0);
$entity
->getEntityTypeId()
->willReturn('test_content');
$data['content entity, matching type, correct value'] = [
TRUE,
EntityContextDefinition::fromEntityType($content),
EntityContextDefinition::fromEntityType($content),
$entity
->reveal(),
];
$data['content entity, incorrect manual constraint'] = [
TRUE,
EntityContextDefinition::fromEntityType($content),
EntityContextDefinition::fromEntityType($content)
->addConstraint('EntityType', 'test_config'),
];
$data['config entity, matching type, no value'] = [
TRUE,
EntityContextDefinition::fromEntityType($config),
EntityContextDefinition::fromEntityType($config),
];
$data['generic entity requirement, specific context'] = [
TRUE,
new ContextDefinition('entity'),
EntityContextDefinition::fromEntityType($config),
];
$data['specific requirement, generic entity context'] = [
FALSE,
EntityContextDefinition::fromEntityType($content),
new ContextDefinition('entity'),
];
return $data;
}