View source
<?php
namespace Drupal\panels\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\user\Entity\User;
class PanelsTest extends WebTestBase {
protected $strictConfigSchema = FALSE;
public static $modules = [
'block',
'page_manager',
'page_manager_ui',
'panels_test',
'layout_plugin_example',
];
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('local_tasks_block');
$this
->drupalPlaceBlock('local_actions_block');
$this
->drupalPlaceBlock('system_branding_block');
$this
->drupalPlaceBlock('page_title_block');
\Drupal::service('theme_handler')
->install([
'bartik',
'classy',
]);
$this
->config('system.theme')
->set('admin', 'classy')
->save();
$this
->drupalLogin($this
->drupalCreateUser([
'administer pages',
'access administration pages',
'view the administration theme',
]));
}
public function testLayoutSettings() {
$this
->drupalGet('admin/structure/page_manager/add');
$edit = [
'id' => 'foo',
'label' => 'foo',
'path' => 'testing',
'variant_plugin_id' => 'panels_variant',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$edit = [
'page_variant_label' => 'Default',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$edit = [
'layout' => 'layout_example_test',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$this
->assertFieldByName('layout_settings_wrapper[layout_settings][setting_1]', 'Default');
$edit = [
'layout_settings_wrapper[layout_settings][setting_1]' => 'Abracadabra',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$this
->clickLink('Add new block');
$this
->clickLink('Powered by Drupal');
$edit = [
'region' => 'top',
];
$this
->drupalPostForm(NULL, $edit, 'Add block');
$this
->drupalPostForm(NULL, [], 'Finish');
$this
->drupalGet('testing');
$this
->assertText('Blah:');
$this
->assertText('Abracadabra');
$this
->assertText('Powered by Drupal');
}
public function testPageTitle() {
$user = User::load($this->loggedInUser
->id());
$user
->setUsername("My User's Name");
$user
->save();
$this
->drupalGet('admin/structure/page_manager/add');
$edit = [
'id' => 'foo',
'label' => 'foo',
'path' => 'testing',
'variant_plugin_id' => 'panels_variant',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$edit = [
'page_variant_label' => 'Default',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$edit = [
'layout' => 'onecol',
];
$this
->drupalPostForm(NULL, $edit, 'Next');
$edit = [
'page_title' => '[user:name]',
];
$this
->drupalPostForm(NULL, $edit, 'Finish');
$this
->drupalGet('testing');
$this
->assertRaw('<h1 class="page-title">My User's Name</h1>');
}
}