function LayoutPluginManagerTest::setUp

Same name in this branch
  1. 10 core/tests/Drupal/KernelTests/Core/Layout/LayoutPluginManagerTest.php \Drupal\KernelTests\Core\Layout\LayoutPluginManagerTest::setUp()
Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php \Drupal\Tests\Core\Layout\LayoutPluginManagerTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php \Drupal\Tests\Core\Layout\LayoutPluginManagerTest::setUp()
  3. 11.x core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php \Drupal\Tests\Core\Layout\LayoutPluginManagerTest::setUp()
  4. 11.x core/tests/Drupal/KernelTests/Core/Layout/LayoutPluginManagerTest.php \Drupal\KernelTests\Core\Layout\LayoutPluginManagerTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php, line 71

Class

LayoutPluginManagerTest
@coversDefaultClass \Drupal\Core\Layout\LayoutPluginManager @group Layout

Namespace

Drupal\Tests\Core\Layout

Code

protected function setUp() : void {
    parent::setUp();
    $this->setUpFilesystem();
    $container = new ContainerBuilder();
    $container->set('string_translation', $this->getStringTranslationStub());
    $this->themeManager = $this->prophesize(ThemeManagerInterface::class);
    $container->set('theme.manager', $this->themeManager
        ->reveal());
    \Drupal::setContainer($container);
    $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
    $this->moduleHandler
        ->moduleExists('module_a')
        ->willReturn(TRUE);
    $this->moduleHandler
        ->moduleExists('theme_a')
        ->willReturn(FALSE);
    $this->moduleHandler
        ->moduleExists('core')
        ->willReturn(FALSE);
    $this->moduleHandler
        ->moduleExists('invalid_provider')
        ->willReturn(FALSE);
    $module_a = new Extension('vfs://root', 'module', 'modules/module_a/module_a.layouts.yml');
    $this->moduleHandler
        ->getModule('module_a')
        ->willReturn($module_a);
    $this->moduleHandler
        ->getModuleDirectories()
        ->willReturn([
        'module_a' => vfsStream::url('root/modules/module_a'),
    ]);
    $this->moduleHandler
        ->alter('layout', Argument::type('array'))
        ->shouldBeCalled();
    $this->themeHandler = $this->prophesize(ThemeHandlerInterface::class);
    $this->themeHandler
        ->themeExists('theme_a')
        ->willReturn(TRUE);
    $this->themeHandler
        ->themeExists('core')
        ->willReturn(FALSE);
    $this->themeHandler
        ->themeExists('invalid_provider')
        ->willReturn(FALSE);
    $theme_a = new Extension('vfs://root', 'theme', 'themes/theme_a/theme_a.layouts.yml');
    $this->themeHandler
        ->getTheme('theme_a')
        ->willReturn($theme_a);
    $this->themeHandler
        ->getThemeDirectories()
        ->willReturn([
        'theme_a' => vfsStream::url('root/themes/theme_a'),
    ]);
    $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);
    $namespaces = new \ArrayObject([
        'Drupal\\Core' => vfsStream::url('root/core/lib/Drupal/Core'),
    ]);
    $class_loader = new ClassLoader();
    $class_loader->addPsr4("Drupal\\Core\\", vfsStream::url("root/core/lib/Drupal/Core"));
    $class_loader->register(TRUE);
    $this->layoutPluginManager = new LayoutPluginManager($namespaces, $this->cacheBackend
        ->reveal(), $this->moduleHandler
        ->reveal(), $this->themeHandler
        ->reveal());
}

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