function BlockConfigEntityUnitTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php \Drupal\Tests\block\Unit\BlockConfigEntityUnitTest::setUp()
  2. 8.9.x core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php \Drupal\Tests\block\Unit\BlockConfigEntityUnitTest::setUp()
  3. 10 core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php \Drupal\Tests\block\Unit\BlockConfigEntityUnitTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php, line 65

Class

BlockConfigEntityUnitTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21block%21src%21Entity%21Block.php/class/Block/11.x" title="Defines a Block configuration entity class." class="local">\Drupal\block\Entity\Block</a> @group block

Namespace

Drupal\Tests\block\Unit

Code

protected function setUp() : void {
    parent::setUp();
    $this->entityTypeId = $this->randomMachineName();
    $this->entityType = $this->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
    $this->entityType
        ->expects($this->any())
        ->method('getProvider')
        ->willReturn('block');
    $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->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
    $this->themeHandler = $this->prophesize(ThemeHandlerInterface::class);
    $container = new ContainerBuilder();
    $container->set('entity_type.manager', $this->entityTypeManager);
    $container->set('module_handler', $this->moduleHandler
        ->reveal());
    $container->set('theme_handler', $this->themeHandler
        ->reveal());
    $container->set('uuid', $this->uuid);
    \Drupal::setContainer($container);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.