PanelizerDefaultsTest.php in Panelizer 8.5
File
tests/src/Functional/PanelizerDefaultsTest.php
View source
<?php
namespace Drupal\Tests\panelizer\Functional;
use Drupal\Tests\BrowserTestBase;
class PanelizerDefaultsTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'field_ui',
'node',
'user',
'panelizer',
];
protected function setUp() {
parent::setUp();
$this
->createContentType([
'type' => 'page',
]);
}
public function test() {
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$account = $this
->createUser([
'administer node display',
]);
$this
->drupalLogin($account);
$view_modes = array_keys(\Drupal::service('entity_display.repository')
->getViewModeOptionsByBundle('node', 'page'));
foreach ($view_modes as $view_mode_name) {
$this
->drupalGet("/admin/structure/types/manage/page/display/{$view_mode_name}");
$assert_session
->statusCodeEquals(200);
$this->container
->get('panelizer')
->setPanelizerSettings('node', 'page', $view_mode_name, [
'enable' => TRUE,
'allow' => TRUE,
'custom' => TRUE,
'default' => 'default',
]);
$session
->reload();
$assert_session
->statusCodeEquals(200);
$assert_session
->checkboxChecked('panelizer[enable]');
$assert_session
->checkboxChecked('panelizer[allow]');
$assert_session
->checkboxChecked('panelizer[custom]');
$page
->uncheckField('panelizer[custom]');
$page
->pressButton('Save');
$assert_session
->statusCodeEquals(200);
$assert_session
->checkboxChecked('panelizer[enable]');
$assert_session
->checkboxChecked('panelizer[allow]');
$assert_session
->fieldNotExists('panelizer[custom]');
$page
->uncheckField('panelizer[enable]');
$page
->pressButton('Save');
$assert_session
->statusCodeEquals(200);
$assert_session
->fieldNotExists('panelizer[enable]');
$assert_session
->fieldNotExists('panelizer[allow]');
$assert_session
->fieldNotExists('panelizer[custom]');
}
}
}