public function DevelLayoutInfoTest::testLayoutList in Devel 8
Same name and namespace in other branches
- 8.3 tests/src/Functional/DevelLayoutInfoTest.php \Drupal\Tests\devel\Functional\DevelLayoutInfoTest::testLayoutList()
- 8.2 tests/src/Functional/DevelLayoutInfoTest.php \Drupal\Tests\devel\Functional\DevelLayoutInfoTest::testLayoutList()
- 4.x tests/src/Functional/DevelLayoutInfoTest.php \Drupal\Tests\devel\Functional\DevelLayoutInfoTest::testLayoutList()
Tests layout info page.
File
- tests/
src/ Functional/ DevelLayoutInfoTest.php, line 61
Class
- DevelLayoutInfoTest
- Tests layout info pages and links.
Namespace
Drupal\Tests\devel\FunctionalCode
public function testLayoutList() {
$this
->drupalGet('/devel/layouts');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Layouts');
$page = $this
->getSession()
->getPage();
// Ensures that the layout table is found.
$table = $page
->find('css', 'table.devel-layout-list');
$this
->assertNotNull($table);
// Ensures that the expected table headers are found.
/** @var $headers \Behat\Mink\Element\NodeElement[] */
$headers = $table
->findAll('css', 'thead th');
$this
->assertEquals(6, count($headers));
$expected_headers = [
'Icon',
'Label',
'Description',
'Category',
'Regions',
'Provider',
];
$actual_headers = array_map(function ($element) {
return $element
->getText();
}, $headers);
$this
->assertSame($expected_headers, $actual_headers);
// Ensures that all the layouts are listed in the table.
$layout_manager = \Drupal::service('plugin.manager.core.layout');
$layouts = $layout_manager
->getDefinitions();
$table_rows = $table
->findAll('css', 'tbody tr');
$this
->assertEquals(count($layouts), count($table_rows));
$index = 0;
foreach ($layouts as $layout) {
$cells = $table_rows[$index]
->findAll('css', 'td');
$this
->assertEquals(6, count($cells));
$cell_layout_icon = $cells[0];
if (empty($layout
->getIconPath())) {
// @todo test that the icon path image is set correctly
}
else {
$this
->assertNull($cell_layout_icon
->getText());
}
$cell_layout_label = $cells[1];
$this
->assertEquals($cell_layout_label
->getText(), $layout
->getLabel());
$cell_layout_description = $cells[2];
$this
->assertEquals($cell_layout_description
->getText(), $layout
->getDescription());
$cell_layout_category = $cells[3];
$this
->assertEquals($cell_layout_category
->getText(), $layout
->getCategory());
$cell_layout_regions = $cells[4];
$this
->assertEquals($cell_layout_regions
->getText(), implode(', ', $layout
->getRegionLabels()));
$cell_layout_provider = $cells[5];
$this
->assertEquals($cell_layout_provider
->getText(), $layout
->getProvider());
$index++;
}
// Ensures that the page is accessible only to the users with the adequate
// permissions.
$this
->drupalLogout();
$this
->drupalGet('devel/layouts');
$this
->assertSession()
->statusCodeEquals(403);
}