You are here

public function PluginManagerTest::testGetThemeImplementations in Layout Plugin (obsolete, use core's Layout Discovery) 8

Tests layout theme implementations.

@covers ::getThemeImplementations

File

tests/src/Unit/PluginManagerTest.php, line 162

Class

PluginManagerTest
Tests the LayoutPluginManager.

Namespace

Drupal\Tests\layout_plugin\Unit

Code

public function testGetThemeImplementations() {

  /** @var LayoutPluginManager|\PHPUnit_Framework_MockObject_MockBuilder $layout_manager */
  $layout_manager = $this
    ->getMockBuilder('Drupal\\layout_plugin\\Plugin\\Layout\\LayoutPluginManager')
    ->disableOriginalConstructor()
    ->setMethods([
    'getDefinitions',
  ])
    ->getMock();
  $layout_manager
    ->method('getDefinitions')
    ->willReturn([
    // Should get template registered automatically.
    'simple_layout' => [
      'path' => 'modules/layout_plugin_test',
      'template_path' => 'modules/layout_plugin_test/templates',
      'template' => 'simple-layout',
      'theme' => 'simple_layout',
    ],
    // Shouldn't get registered automatically.
    'complex_layout' => [
      'path' => 'modules/layout_plugin_test',
      'theme' => 'complex_layout',
    ],
  ]);
  $theme_registry = $layout_manager
    ->getThemeImplementations();
  $this
    ->assertEquals([
    'simple_layout' => [
      'render element' => 'content',
      'template' => 'simple-layout',
      'path' => 'modules/layout_plugin_test/templates',
    ],
  ], $theme_registry);
}