function ConfigEntityStorageTest::setUp
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::setUp()
- 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::setUp()
- 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::setUp()
@covers ::__construct
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityStorageTest.php, line 109
Class
- ConfigEntityStorageTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
protected function setUp() : void {
parent::setUp();
$this->entityTypeId = 'test_entity_type';
$entity_type = new ConfigEntityType([
'id' => $this->entityTypeId,
'class' => get_class($this->getMockEntity()),
'provider' => 'the_provider',
'config_prefix' => 'the_config_prefix',
'entity_keys' => [
'id' => 'id',
'uuid' => 'uuid',
'langcode' => 'langcode',
],
'config_export' => [
'id',
],
'list_cache_tags' => [
$this->entityTypeId . '_list',
],
]);
$this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
$this->uuidService = $this->prophesize(UuidInterface::class);
$this->languageManager = $this->prophesize(LanguageManagerInterface::class);
$this->languageManager
->getCurrentLanguage()
->willReturn(new Language([
'id' => 'hu',
]));
$this->configFactory = $this->prophesize(ConfigFactoryInterface::class);
$this->entityQuery = $this->prophesize(QueryInterface::class);
$entity_query_factory = $this->prophesize(QueryFactoryInterface::class);
$entity_query_factory->get($entity_type, 'AND')
->willReturn($this->entityQuery
->reveal());
$this->entityStorage = new ConfigEntityStorage($entity_type, $this->configFactory
->reveal(), $this->uuidService
->reveal(), $this->languageManager
->reveal(), new MemoryCache(new Time()));
$this->entityStorage
->setModuleHandler($this->moduleHandler
->reveal());
$entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
$entity_type_manager->getDefinition('test_entity_type')
->willReturn($entity_type);
$this->cacheTagsInvalidator = $this->prophesize(CacheTagsInvalidatorInterface::class);
$typed_config_manager = $this->prophesize(TypedConfigManagerInterface::class);
$typed_config_manager->getDefinition(Argument::containingString('the_provider.the_config_prefix.'))
->willReturn([
'mapping' => [
'id' => '',
'uuid' => '',
'dependencies' => '',
],
]);
$this->configManager = $this->prophesize(ConfigManagerInterface::class);
$container = new ContainerBuilder();
$container->set('entity_type.manager', $entity_type_manager->reveal());
$container->set('entity.query.config', $entity_query_factory->reveal());
$container->set('config.typed', $typed_config_manager->reveal());
$container->set('cache_tags.invalidator', $this->cacheTagsInvalidator
->reveal());
$container->set('config.manager', $this->configManager
->reveal());
$container->set('language_manager', $this->languageManager
->reveal());
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.