function LayoutPluginManagerTest::setUp

Same name and namespace 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. 10 core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php \Drupal\Tests\Core\Layout\LayoutPluginManagerTest::setUp()

Overrides UnitTestCase::setUp

File

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

Class

LayoutPluginManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Layout%21LayoutPluginManager.php/class/LayoutPluginManager/11.x" title="Provides a plugin manager for layouts." class="local">\Drupal\Core\Layout\LayoutPluginManager</a> @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());
    \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.