diff --git a/src/Tests/PanelizerNodeFunctionalTest.php b/src/Tests/PanelizerNodeFunctionalTest.php index 668afe6..6a40b59 100644 --- a/src/Tests/PanelizerNodeFunctionalTest.php +++ b/src/Tests/PanelizerNodeFunctionalTest.php @@ -46,24 +46,82 @@ class PanelizerNodeFunctionalTest extends WebTestBase { $user = $this->drupalCreateUser([ 'administer node display', 'administer nodes', + 'administer pages', 'administer content types', 'create page content', + 'create article content', 'administer panelizer', 'access panels in-place editing', - 'use panels in place editing', + 'view the administration theme', ]); $this->drupalLogin($user); + } - $this->drupalPostForm('admin/structure/types/manage/page/display', [ - 'panelizer[enable]' => TRUE, - 'panelizer[custom]' => TRUE, - ], 'Save'); + /** + * Tests the admin interface to set a default layout for a bundle. + */ + public function testWizardUI() { + $this->drupalGet('admin/structure/types/manage/article/display'); + $this->clickLink('Panelize this view mode'); + // General settings step. + $edit = ['custom' => TRUE]; + + // Contexts step. + $this->drupalPostForm(NULL, $edit, 'Next'); + $this->assertText('panelizer_context_entity', 'The current entity context is present.'); + + // Layout selection step. + $this->drupalPostForm(NULL, [], 'Next'); + + // Content step. Add the Node block to the top region. + $this->drupalPostForm(NULL, [], 'Next'); + $this->clickLink('Add new block'); + $this->clickLink('Title'); + $edit = [ + 'region' => 'middle', + ]; + $this->drupalPostForm(NULL, $edit, 'Add block'); + + // Finish the wizard. + $this->drupalPostForm(NULL, [], 'Finish'); + + // Check that the general setting was saved. + $this->assertFieldChecked('edit-custom'); + + // Now change the setting and then cancel changes. + $this->drupalPostForm(NULL, ['custom' => FALSE], 'Update'); + $this->assertNoFieldChecked('edit-custom'); + $this->drupalPostForm(NULL, [], 'Cancel'); + $this->assertFieldChecked('edit-custom'); + + // Now change and save the general setting. + $this->drupalPostForm(NULL, ['custom' => FALSE], 'Update and save'); + $this->assertNoFieldChecked('edit-custom'); + $this->drupalPostForm(NULL, [], 'Cancel'); + $this->assertNoFieldChecked('edit-custom'); + + // Add another block at the Content step and then save changes. + $this->clickLink('Content'); + $this->clickLink('Add new block'); + $this->clickLink('Body'); + $edit = [ + 'region' => 'middle', + ]; + $this->drupalPostForm(NULL, $edit, 'Add block'); + $this->assertText('entity_field:node:body', 'The body block was added successfully.'); + $this->drupalPostForm(NULL, [], 'Save'); + $this->clickLink('Content'); + $this->assertText('entity_field:node:body', 'The body block was saved successfully.'); } /** * Tests rendering a node with Panelizer default. */ public function testPanelizerDefault() { + $this->drupalPostForm('admin/structure/types/manage/page/display', [ + 'panelizer[enable]' => TRUE, + 'panelizer[custom]' => TRUE, + ], 'Save'); /** @var \Drupal\panelizer\PanelizerInterface $panelizer */ $panelizer = \Drupal::service('panelizer'); $displays = $panelizer->getDefaultPanelsDisplays('node', 'page', 'default');