function BlockConfigEntityUnitTest::setUp

Same name 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. 11.x 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 \Drupal\block\Entity\Block @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.