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 $test_route;
protected $window_size = [
1024,
768,
];
protected static $modules = [
'field_ui',
'node',
'panels',
'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
->drupalGet('admin/structure/types/manage/page/display');
$this
->submitForm([
'panelizer[enable]' => 1,
], t('Save'));
$this
->drupalGet('node/add/page');
$this
->submitForm([
'title[0][value]' => 'Test Node',
], t('Save'));
$this->test_route = 'node/1';
}
public function testUserEditSession() {
$this
->visitIPERoute();
$this
->assertSession()
->elementExists('css', '.layout--onecol');
$this
->changeLayout('Columns: 2', 'layout_twocol');
$this
->assertSession()
->elementExists('css', '.layout--twocol');
$this
->assertSession()
->elementNotExists('css', '.layout--onecol');
$this
->drupalGet('node/add/page');
$this
->submitForm([
'title[0][value]' => 'Test Node 2',
], t('Save'));
$this->test_route = 'node/2';
$this
->visitIPERoute();
$this
->assertSession()
->elementExists('css', '.layout--onecol');
$this
->assertSession()
->elementNotExists('css', '.layout--twocol');
}
public function testIPEIsLoaded() {
$this
->visitIPERoute();
$this
->assertIPELoaded();
}
public function testIPEAddBlock() {
$this
->visitIPERoute();
$this
->addBlock('System', 'system_breadcrumb_block');
}
public function testIPEChangeLayout() {
$this
->visitIPERoute();
$this
->changeLayout('Columns: 2', 'layout_twocol');
$this
->waitUntilVisible('.layout--twocol', 10000, 'Layout changed to two column.');
}
protected function visitIPERoute() {
$this
->drupalGet($this->test_route);
call_user_func_array([
$this
->getSession(),
'resizeWindow',
], $this->window_size);
}
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');
$layout_form = $this
->getSession()
->getPage()
->find('css', '.panels-ipe-layout-form');
if ($layout_form) {
$layout_form
->pressButton('Change Layout');
}
$this
->waitUntilVisible('[data-tab-id="edit"].active');
}
}