function ConfigEntityBaseUnitTest::setUp
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::setUp()
- 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::setUp()
- 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityBaseUnitTest.php, line 114
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
protected function setUp() : void {
parent::setUp();
$this->id = $this->randomMachineName();
$values = [
'id' => $this->id,
'langcode' => 'en',
'uuid' => '3bb9ee60-bea5-4622-b89b-a63319d10b3a',
];
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->createMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityTypeInterface');
$this->entityType
->expects($this->any())
->method('getProvider')
->willReturn(static::PROVIDER);
$this->entityType
->expects($this->any())
->method('getConfigPrefix')
->willReturn('test_provider.' . $this->entityTypeId);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager
->expects($this->any())
->method('getDefinition')
->with($this->entityTypeId)
->willReturn($this->entityType);
$this->uuid = $this->createMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$this->languageManager = $this->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
$this->languageManager
->expects($this->any())
->method('getLanguage')
->with('en')
->willReturn(new Language([
'id' => 'en',
]));
$this->cacheTagsInvalidator = $this->createMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
$this->typedConfigManager = $this->createMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
$this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
$this->themeHandler = $this->prophesize(ThemeHandlerInterface::class);
$container = new ContainerBuilder();
$container->set('entity_type.manager', $this->entityTypeManager);
$container->set('uuid', $this->uuid);
$container->set('language_manager', $this->languageManager);
$container->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
$container->set('config.typed', $this->typedConfigManager);
$container->set('module_handler', $this->moduleHandler
->reveal());
$container->set('theme_handler', $this->themeHandler
->reveal());
\Drupal::setContainer($container);
$this->entity = $this->getMockBuilder(ConfigEntityBaseMockableClass::class)
->setConstructorArgs([
$values,
$this->entityTypeId,
])
->onlyMethods([])
->getMock();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.