protected function PanelizerTestTrait::addPanelizerDefault in Panelizer 8.5
Same name and namespace in other branches
- 8.4 tests/src/Functional/PanelizerTestTrait.php \Drupal\Tests\panelizer\Functional\PanelizerTestTrait::addPanelizerDefault()
Parameters
string $content_type: The content type, i.e. the node bundle ID, to configure; defaults to 'page'.
File
- tests/
src/ Functional/ PanelizerTestTrait.php, line 138
Class
- PanelizerTestTrait
- Contains helper methods for writing functional tests of Panelizer.
Namespace
Drupal\Tests\panelizer\FunctionalCode
protected function addPanelizerDefault($content_type = 'page', $display = 'default') {
$label = $this
->getRandomGenerator()
->word(16);
$id = strtolower($label);
$default_id = "node__{$content_type}__{$display}__{$id}";
$options = [
'query' => [
'js' => 'nojs',
],
];
$path = "admin/structure/types/manage/{$content_type}/display";
if (!empty($display)) {
$path .= '/' . $display;
}
$this
->drupalGet($path);
$this
->assertResponse(200);
$this
->clickLink('Add a new Panelizer default display');
// Step 1: Enter the default's label and ID.
$edit = [
'id' => $id,
'label' => $label,
];
$this
->submitForm($edit, 'Next');
$this
->assertResponse(200);
// Step 2: Define contexts.
$this
->assertUrl("admin/structure/panelizer/add/{$default_id}/contexts", $options);
$this
->submitForm([], 'Next');
$this
->assertResponse(200);
// Step 3: Select layout.
$this
->assertUrl("admin/structure/panelizer/add/{$default_id}/layout", $options);
$this
->submitForm([], 'Next');
$this
->assertResponse(200);
// Step 4: Select content.
$this
->assertUrl("admin/structure/panelizer/add/{$default_id}/content", $options);
$this
->submitForm([], 'Finish');
$this
->assertResponse(200);
return $id;
}