You are here

public function PanelizerNodeTranslationsTest::_testWizardUI in Panelizer 8.5

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/PanelizerNodeTranslationsTest.php \Drupal\Tests\panelizer\Functional\PanelizerNodeTranslationsTest::_testWizardUI()

Tests the admin interface to set a default layout for a bundle.

File

tests/src/Functional/PanelizerNodeTranslationsTest.php, line 60

Class

PanelizerNodeTranslationsTest
Test node translation handling in Panelizer.

Namespace

Drupal\Tests\panelizer\Functional

Code

public function _testWizardUI() {
  $this->container
    ->get('panelizer')
    ->setPanelizerSettings('node', $this->bundle, 'default', [
    'enable' => TRUE,
    'allow' => FALSE,
    'custom' => TRUE,
    'default' => 'default',
  ]);

  // Enter the wizard.
  $this
    ->drupalGet("admin/structure/panelizer/edit/{$this->entityTypeId}__{$this->bundle}__default__default");
  $this
    ->assertResponse(200);
  $this
    ->assertText('Wizard Information');
  $this
    ->assertField('edit-label');

  // Contexts step.
  $this
    ->clickLink('Contexts');
  $this
    ->assertText('@panelizer.entity_context:entity', 'The current entity context is present.');

  // Layout selection step.
  $this
    ->clickLink('Layout');
  $this
    ->assertSession()
    ->buttonExists('edit-update-layout');

  // Content step. Add the Node block to the top region.
  // @todo The index will have to change if the install profile is changed.
  $this
    ->clickLink('Content', 1);
  $this
    ->clickLink('Add new block');
  $this
    ->clickLink('Title');
  $edit = [
    'region' => 'content',
  ];
  $this
    ->submitForm($edit, 'Add block');
  $this
    ->assertResponse(200);

  // Finish the wizard.
  $this
    ->submitForm([], 'Update and save');
  $this
    ->assertResponse(200);

  // Confirm this returned to the main wizard page.
  $this
    ->assertText('Wizard Information');
  $this
    ->assertField('edit-label');

  // Return to the Manage Display page, which is where the Cancel button
  // currently sends you. That's a UX WTF and should be fixed...
  $this
    ->submitForm([], 'Cancel');
  $this
    ->assertResponse(200);

  // Confirm the page is back to the content type settings page.
  $this
    ->assertFieldChecked('edit-panelizer-custom');

  // Now change and save the general setting.
  $edit = [
    'panelizer[custom]' => FALSE,
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertResponse(200);
  $this
    ->assertNoFieldChecked('edit-panelizer-custom');

  // Add another block at the Content step and then save changes.
  $this
    ->drupalGet("admin/structure/panelizer/edit/{$this->entityTypeId}__{$this->bundle}__default__default/content");
  $this
    ->assertResponse(200);
  $this
    ->clickLink('Add new block');
  $this
    ->clickLink('Body');
  $edit = [
    'region' => 'content',
  ];
  $this
    ->submitForm($edit, 'Add block');
  $this
    ->assertResponse(200);
  $this
    ->assertText("entity_field:{$this->entityTypeId}:body", 'The body block was added successfully.');
  $this
    ->submitForm([], 'Save');
  $this
    ->assertResponse(200);
  $this
    ->clickLink('Content', 1);
  $this
    ->assertText("entity_field:{$this->entityTypeId}:body", 'The body block was saved successfully.');

  // Check that the Manage Display tab changed now that Panelizer is set up.
  // Also, the field display table should be hidden.
  $this
    ->assertNoRaw('<div id="field-display-overview-wrapper">');

  // Disable Panelizer for the default display mode. This should bring back
  // the field overview table at Manage Display and not display the link to
  // edit the default Panelizer layout.
  $this
    ->unpanelize($this->bundle);
  $this
    ->assertNoLinkByHref("admin/structure/panelizer/edit/{$this->entityTypeId}__{$this->bundle}__default");
  $this
    ->assertRaw('<div id="field-display-overview-wrapper">');
}