View source
<?php
namespace Drupal\Tests\panelizer\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\panels_ipe\FunctionalJavascript\PanelsIPETestTrait;
class PanelizerIntegrationTest extends WebDriverTestBase {
use PanelsIPETestTrait;
protected $defaultTheme = 'stark';
protected static $modules = [
'field_ui',
'node',
'panels_ipe',
'panelizer',
'system',
];
protected function setUp() {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'access content',
'access panels in-place editing',
'administer blocks',
'administer content types',
'administer nodes',
'administer node display',
'administer panelizer',
]);
$this
->drupalLogin($admin_user);
$this
->createContentType([
'type' => 'page',
'name' => 'Basic Page',
]);
$this->container
->get('panelizer')
->setPanelizerSettings('node', 'page', 'default', [
'enable' => TRUE,
'allow' => FALSE,
'custom' => FALSE,
'default' => 'default',
]);
$this
->getSession()
->resizeWindow(1024, 768);
$this
->drupalGet('node/add/page');
$this
->submitForm([
'title[0][value]' => 'Test Node',
], t('Save'));
}
public function testUserEditSession() {
$assert_session = $this
->assertSession();
$this
->drupalGet('/node/1');
$this
->assertIPELoaded();
$assert_session
->elementExists('css', '.layout--onecol');
$this
->changeLayout('Columns: 2', 'layout_twocol');
$assert_session
->elementExists('css', '.layout--twocol');
$assert_session
->elementNotExists('css', '.layout--onecol');
$this
->drupalGet('node/add/page');
$this
->submitForm([
'title[0][value]' => 'Test Node 2',
], t('Save'));
$this
->drupalGet('/node/2');
$assert_session
->elementExists('css', '.layout--onecol');
$assert_session
->elementNotExists('css', '.layout--twocol');
}
public function testIPEAddBlock() {
$this
->drupalGet('/node/1');
$this
->addBlock('System', 'system_breadcrumb_block');
}
public function testIPEChangeLayout() {
$this
->drupalGet('/node/1');
$this
->changeLayout('Columns: 2', 'layout_twocol');
$this
->waitUntilVisible('.layout--twocol', 10000, 'Layout changed to two column.');
}
protected function changeLayout($category, $layout_id) {
$this
->clickAndWait('[data-tab-id="change_layout"]');
$this
->waitUntilNotPresent('.ipe-icon-loading');
$this
->clickAndWait('[data-category="' . $category . '"]');
$this
->clickAndWait('[data-layout-id="' . $layout_id . '"]');
$this
->waitUntilNotPresent('.ipe-icon-loading');
$page = $this
->getSession()
->getPage();
$label_field = $page
->findField('Administrative label');
if ($label_field) {
$label_field
->setValue($this
->randomString());
$page
->pressButton('Change Layout');
}
$this
->waitUntilVisible('[data-tab-id="edit"].active');
}
}