View source
<?php
namespace Drupal\Tests\page_manager_ui\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\BrowserTestBase;
class PageParametersTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'block',
'page_manager_ui',
'node',
];
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
$this
->drupalPlaceBlock('local_tasks_block');
$this
->drupalPlaceBlock('local_actions_block');
$this
->drupalPlaceBlock('system_branding_block');
$this
->drupalPlaceBlock('page_title_block');
$this
->drupalLogin($this
->drupalCreateUser([
'administer pages',
'access administration pages',
'view the administration theme',
'create article content',
]));
}
public function testParameters() {
$node = $this
->drupalCreateNode([
'type' => 'article',
]);
$this
->drupalGet('admin/structure');
$this
->clickLink('Pages');
$this
->clickLink('Add page');
$edit = [
'id' => 'foo',
'label' => 'Foo',
'path' => 'admin/foo/{node}',
'variant_plugin_id' => 'block_display',
'use_admin_theme' => TRUE,
'description' => 'Sample test page.',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$this
->assertTitle('Page parameters | Drupal');
$access_path = 'admin/structure/page_manager/add/foo/parameters';
$this
->assertUrl($access_path . '?js=nojs');
$this
->assertNoText('There are no parameters defined for this page.');
$this
->clickLink('Edit');
$this
->assertTitle('Edit parameter | Drupal');
$edit = [
'type' => 'entity:node',
];
$this
->drupalPostForm(NULL, $edit, 'Update parameter');
$this
->assertText('The node parameter has been updated.');
$this
->drupalPostForm(NULL, [], 'Next');
$this
->drupalPostForm(NULL, [], 'Next');
$this
->clickLink('Add new block');
$this
->clickLink('Entity view (Content)');
$edit = [
'region' => 'top',
];
$this
->drupalPostForm(NULL, $edit, 'Add block');
$this
->drupalPostForm(NULL, [], 'Finish');
$this
->assertRaw(new FormattableMarkup('The page %label has been added.', [
'%label' => 'Foo',
]));
$this
->drupalGet('admin/foo/' . $node
->id());
$this
->assertResponse(200);
$this
->assertText($node
->getTitle());
}
}