public function DevelContainerInfoTest::testParameterList in Devel 8
Same name and namespace in other branches
- 8.3 tests/src/Functional/DevelContainerInfoTest.php \Drupal\Tests\devel\Functional\DevelContainerInfoTest::testParameterList()
- 8.2 tests/src/Functional/DevelContainerInfoTest.php \Drupal\Tests\devel\Functional\DevelContainerInfoTest::testParameterList()
- 4.x tests/src/Functional/DevelContainerInfoTest.php \Drupal\Tests\devel\Functional\DevelContainerInfoTest::testParameterList()
Tests parameter list page.
File
- tests/
src/ Functional/ DevelContainerInfoTest.php, line 163
Class
- DevelContainerInfoTest
- Tests container info pages and links.
Namespace
Drupal\Tests\devel\FunctionalCode
public function testParameterList() {
// Ensures that the page works as expected.
$this
->drupalGet('/devel/container/parameter');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('Container parameters');
$this
->assertContainerInfoLocalTasks();
$page = $this
->getSession()
->getPage();
// Ensures that the parameters table is found.
$table = $page
->find('css', 'table.devel-parameter-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(2, count($headers));
$expected_headers = [
'Name',
'Operations',
];
$actual_headers = array_map(function ($element) {
return $element
->getText();
}, $headers);
$this
->assertSame($expected_headers, $actual_headers);
// Ensures that all the parameters are listed in the table.
$cached_definition = \Drupal::service('kernel')
->getCachedContainerDefinition();
$this
->assertNotNull($cached_definition);
$rows = $table
->findAll('css', 'tbody tr');
$this
->assertEquals(count($cached_definition['parameters']), count($rows));
// Tests the presence of some parameters in the table.
$expected_parameters = [
'container.modules',
'cache_bins',
'factory.keyvalue',
'twig.config',
];
foreach ($expected_parameters as $parameter_name) {
$row = $table
->find('css', sprintf('tbody tr:contains("%s")', $parameter_name));
$this
->assertNotNull($row);
/** @var $cells \Behat\Mink\Element\NodeElement[] */
$cells = $row
->findAll('css', 'td');
$this
->assertEquals(2, count($cells));
$cell_parameter_name = $cells[0];
$this
->assertEquals($parameter_name, $cell_parameter_name
->getText());
$this
->assertTrue($cell_parameter_name
->hasClass('table-filter-text-source'));
$cell_operations = $cells[1];
$actual_href = $cell_operations
->findLink('Devel')
->getAttribute('href');
$expected_href = Url::fromRoute('devel.container_info.parameter.detail', [
'parameter_name' => $parameter_name,
])
->toString();
$this
->assertEquals($expected_href, $actual_href);
}
// Ensures that the page is accessible ony to users with the adequate
// permissions.
$this
->drupalLogout();
$this
->drupalGet('devel/container/service');
$this
->assertSession()
->statusCodeEquals(403);
}