You are here

protected function PageManagerAdminTest::doTestAddPage in Page Manager 8.4

Same name in this branch
  1. 8.4 page_manager_ui/tests/src/Functional/PageManagerAdminTest.php \Drupal\Tests\page_manager_ui\Functional\PageManagerAdminTest::doTestAddPage()
  2. 8.4 page_manager_ui/tests/src/FunctionalJavascript/PageManagerAdminTest.php \Drupal\Tests\page_manager_ui\FunctionalJavascript\PageManagerAdminTest::doTestAddPage()

Tests adding a page.

1 call to PageManagerAdminTest::doTestAddPage()
PageManagerAdminTest::testAdmin in page_manager_ui/tests/src/FunctionalJavascript/PageManagerAdminTest.php
Tests the Page Manager admin UI.

File

page_manager_ui/tests/src/FunctionalJavascript/PageManagerAdminTest.php, line 57

Class

PageManagerAdminTest
Tests the admin UI for page entities.

Namespace

Drupal\Tests\page_manager_ui\FunctionalJavascript

Code

protected function doTestAddPage() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet('admin/structure');
  $this
    ->clickLink('Pages');
  $assert_session
    ->pageTextContains('Add a new page.');

  // Add a new page without a label.
  $this
    ->clickLink('Add page');
  $this
    ->getSession()
    ->getPage()
    ->fillField('label', 'Foo');
  $this
    ->assertNotEmpty($assert_session
    ->waitForText('Machine name: foo'));
  $edit = [
    'path' => 'admin/foo',
    'variant_plugin_id' => 'http_status_code',
    'use_admin_theme' => TRUE,
    'description' => 'This is our first test page.',
    // Go through all available steps (we skip them all in doTestSecondPage())
    'wizard_options[access]' => TRUE,
    'wizard_options[selection]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Next');

  // Test the 'Page access' step.
  $this
    ->assertTitle('Page access | Drupal');
  $access_path = 'admin/structure/page_manager/add/foo/access';
  $this
    ->assertUrl($access_path . '?js=nojs');
  $this
    ->drupalPostForm(NULL, [], 'Next');

  // Test the 'Selection criteria' step.
  $this
    ->assertTitle('Selection criteria | Drupal');
  $selection_path = 'admin/structure/page_manager/add/foo/selection';
  $this
    ->assertUrl($selection_path . '?js=nojs');
  $this
    ->drupalPostForm(NULL, [], 'Next');

  // Configure the variant.
  $edit = [
    'page_variant_label' => 'Status Code',
    'variant_settings[status_code]' => 200,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Finish');
  $this
    ->assertRaw(new FormattableMarkup('The page %label has been added.', [
    '%label' => 'Foo',
  ]));

  // We've gone from the add wizard to the edit wizard.
  $this
    ->drupalGet('admin/structure/page_manager/manage/foo/general');
  $this
    ->drupalGet('admin/foo');
  $this
    ->assertTitle('Foo | Drupal');

  // Change the status code to 403.
  $this
    ->drupalGet('admin/structure/page_manager/manage/foo/page_variant__foo-http_status_code-0__general');
  $edit = [
    'variant_settings[status_code]' => 403,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Update and save');
}