You are here

protected function BlockLocalTasksTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php \Drupal\Tests\block\Unit\Menu\BlockLocalTasksTest::setUp()
  2. 9 core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php \Drupal\Tests\block\Unit\Menu\BlockLocalTasksTest::setUp()

Overrides LocalTaskIntegrationTestBase::setUp

File

core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php, line 15

Class

BlockLocalTasksTest
Tests block local tasks.

Namespace

Drupal\Tests\block\Unit\Menu

Code

protected function setUp() : void {
  $this->directoryList = [
    'block' => 'core/modules/block',
  ];
  parent::setUp();
  $config_factory = $this
    ->getConfigFactoryStub([
    'system.theme' => [
      'default' => 'test_c',
    ],
  ]);
  $themes = [];
  $themes['test_a'] = (object) [
    'status' => 1,
    'info' => [
      'name' => 'test_a',
      'hidden' => TRUE,
    ],
  ];
  $themes['test_b'] = (object) [
    'status' => 1,
    'info' => [
      'name' => 'test_b',
    ],
  ];
  $themes['test_c'] = (object) [
    'status' => 1,
    'info' => [
      'name' => 'test_c',
    ],
  ];
  $theme_handler = $this
    ->createMock('Drupal\\Core\\Extension\\ThemeHandlerInterface');
  $theme_handler
    ->expects($this
    ->any())
    ->method('listInfo')
    ->will($this
    ->returnValue($themes));
  $theme_handler
    ->expects($this
    ->any())
    ->method('hasUi')
    ->willReturnMap([
    [
      'test_a',
      FALSE,
    ],
    [
      'test_b',
      TRUE,
    ],
    [
      'test_c',
      TRUE,
    ],
  ]);
  $container = new ContainerBuilder();
  $container
    ->set('config.factory', $config_factory);
  $container
    ->set('theme_handler', $theme_handler);
  $container
    ->setParameter('app.root', $this->root);
  \Drupal::setContainer($container);
}