class LayoutPluginManagerExceptionTest

Tests Drupal\Core\Layout\LayoutPluginManager exceptions.

These tests were separated from LayoutPluginManagerTest because they would not execute properly due to all the expectations added in its setUp().

Attributes

#[Group('Layout')]

Hierarchy

Expanded class hierarchy of LayoutPluginManagerExceptionTest

File

core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerExceptionTest.php, line 23

Namespace

Drupal\Tests\Core\Layout
View source
class LayoutPluginManagerExceptionTest extends UnitTestCase {
  
  /**
   * Tests ::processDefinition() with a layout that doesn't have a label.
   *
   * @legacy-covers ::processDefinition
   */
  public function testProcessDefinitionWithMissingLayoutLabel() : void {
    $this->expectException(InvalidPluginDefinitionException::class);
    $this->expectExceptionMessage('The "test_layout" layout definition must have a label.');
    $definition = new LayoutDefinition([
      'id' => 'a_label_less_layout',
      'class' => LayoutDefault::class,
    ]);
    $layoutPluginManager = new LayoutPluginManager(new \ArrayObject([
      'Drupal\\Core',
    ]), $this->createStub(CacheBackendInterface::class), $this->createStub(ModuleHandlerInterface::class), $this->createStub(ThemeHandlerInterface::class));
    $layoutPluginManager->processDefinition($definition, 'test_layout');
  }

}

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