protected function BlockRepositoryTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/block/tests/src/Unit/BlockRepositoryTest.php \Drupal\Tests\block\Unit\BlockRepositoryTest::setUp()
- 9 core/modules/block/tests/src/Unit/BlockRepositoryTest.php \Drupal\Tests\block\Unit\BlockRepositoryTest::setUp()
File
- core/
modules/ block/ tests/ src/ Unit/ BlockRepositoryTest.php, line 39
Class
- BlockRepositoryTest
- @coversDefaultClass \Drupal\block\BlockRepository @group block
Namespace
Drupal\Tests\block\UnitCode
protected function setUp() : void {
parent::setUp();
$active_theme = $this
->getMockBuilder('Drupal\\Core\\Theme\\ActiveTheme')
->disableOriginalConstructor()
->getMock();
$this->theme = $this
->randomMachineName();
$active_theme
->expects($this
->atLeastOnce())
->method('getName')
->willReturn($this->theme);
$active_theme
->expects($this
->atLeastOnce())
->method('getRegions')
->willReturn([
'top',
'center',
'bottom',
]);
$theme_manager = $this
->createMock('Drupal\\Core\\Theme\\ThemeManagerInterface');
$theme_manager
->expects($this
->atLeastOnce())
->method('getActiveTheme')
->will($this
->returnValue($active_theme));
$this->contextHandler = $this
->createMock('Drupal\\Core\\Plugin\\Context\\ContextHandlerInterface');
$this->blockStorage = $this
->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject $entity_type_manager */
$entity_type_manager = $this
->createMock(EntityTypeManagerInterface::class);
$entity_type_manager
->expects($this
->any())
->method('getStorage')
->willReturn($this->blockStorage);
$this->blockRepository = new BlockRepository($entity_type_manager, $theme_manager, $this->contextHandler);
}