function LayoutDerivativesTest::testDerivatives in Layout 8.2
Tests for module/theme layout derivatives.
File
- lib/
Drupal/ layout/ Tests/ LayoutDerivativesTest.php, line 35 - Definition of Drupal\layout\Tests\LayoutDerivativesTest.
Class
- LayoutDerivativesTest
- Tests the layout system derivatives.
Namespace
Drupal\layout\TestsCode
function testDerivatives() {
$manager = $this->container
->get('plugin.manager.layout');
$definitions = $manager
->getDefinitions();
$this
->assertTrue(is_array($definitions), 'Definitions found.');
$this
->assertTrue(count($definitions) == 4, 'Four definitions available.');
$this
->assertTrue(isset($definitions['static_layout:layout_test__one-col']), 'One column layout found.');
$this
->assertTrue(isset($definitions['static_layout:layout_test_theme__two-col']), 'Two column layout found.');
// Get a one column layout instance. This is defined under the layout_test
// module.
$layout = $manager
->createInstance('static_layout:layout_test__one-col', array());
// Verify the expected regions are properly available.
$regions = $layout
->getRegions();
$this
->assertTrue(is_array($regions), 'Regions array present.');
$this
->assertTrue(count($regions) == 1, 'One region defined.');
$this
->assertTrue(isset($regions['middle']), 'Middle region found.');
// Render the layout and look at whether expected region names and classes
// were in the output.
$render = $this
->renderLayoutDemonstration($layout);
$this
->drupalSetContent($render);
$this
->assertText('Middle column');
$this
->assertRaw('class="layout-display layout-one-col');
// Get the two column page layout defined by the layout test theme.
$layout = $manager
->createInstance('static_layout:layout_test_theme__two-col', array());
// Verify the expected regions are properly available.
$regions = $layout
->getRegions();
$this
->assertTrue(is_array($regions), 'Regions array present.');
$this
->assertTrue(count($regions) == 2, 'Two regions defined.');
$this
->assertTrue(isset($regions['left']), 'Left region found.');
$this
->assertTrue(isset($regions['right']), 'Right region found.');
// Render the layout and look at whether expected region names and classes
// were in the output.
$render = $this
->renderLayoutDemonstration($layout);
$this
->drupalSetContent($render);
$this
->assertText('Left side');
$this
->assertText('Right side');
$this
->assertRaw('<div class="layout-region layout-col-right">');
}