function EntityContextDefinitionIsSatisfiedTest::setUp
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php \Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::setUp()
- 10 core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php \Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::setUp()
- 11.x core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php \Drupal\Tests\Core\Plugin\Context\EntityContextDefinitionIsSatisfiedTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ EntityContextDefinitionIsSatisfiedTest.php, line 48
Class
- EntityContextDefinitionIsSatisfiedTest
- @coversDefaultClass \Drupal\Core\Plugin\Context\EntityContextDefinition @group Plugin
Namespace
Drupal\Tests\Core\Plugin\ContextCode
protected function setUp() : void {
parent::setUp();
$namespaces = new \ArrayObject([
'Drupal\\Core\\TypedData' => $this->root . '/core/lib/Drupal/Core/TypedData',
'Drupal\\Core\\Validation' => $this->root . '/core/lib/Drupal/Core/Validation',
'Drupal\\Core\\Entity' => $this->root . '/core/lib/Drupal/Core/Entity',
]);
$cache_backend = new NullBackend('cache');
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$class_resolver = $this->prophesize(ClassResolverInterface::class);
$class_resolver->getInstanceFromDefinition(Argument::type('string'))
->will(function ($arguments) {
$class_name = $arguments[0];
return new $class_name();
});
$type_data_manager = new TypedDataManager($namespaces, $cache_backend, $module_handler->reveal(), $class_resolver->reveal());
$type_data_manager->setValidationConstraintManager(new ConstraintManager($namespaces, $cache_backend, $module_handler->reveal()));
$this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
$this->entityTypeBundleInfo = $this->prophesize(EntityTypeBundleInfoInterface::class);
$string_translation = new TranslationManager(new LanguageDefault([]));
$container = new ContainerBuilder();
$container->set('typed_data_manager', $type_data_manager);
$container->set('entity_type.manager', $this->entityTypeManager
->reveal());
$container->set('entity_type.bundle.info', $this->entityTypeBundleInfo
->reveal());
$container->set('string_translation', $string_translation);
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.