You are here

public function StaticPageTest::testSettingsForm in Static Page 8

Tests the Static Page settings form.

File

tests/src/Functional/StaticPageTest.php, line 70

Class

StaticPageTest
Test basic module functionality: settings form, etc.

Namespace

Drupal\Tests\static_page\Functional

Code

public function testSettingsForm() {
  $this
    ->drupalGet(Url::fromRoute('<front>'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet(Url::fromRoute('static_page.settings'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $button = $this
    ->getSession()
    ->getPage()
    ->findButton('Save configuration');
  $this
    ->assertNotEmpty($button);
  $options = $this
    ->xpath('//select[@name="fields[article]"]/option');
  $this
    ->assertCount(2, $options);
  $this
    ->assertSession()
    ->optionExists('fields[article]', 'body');
  $this
    ->assertSession()
    ->optionExists('fields[article]', '-- None --');
  $options = $this
    ->xpath('//select[@name="fields[page]"]/option');
  $this
    ->assertCount(2, $options);
  $this
    ->assertSession()
    ->optionExists('fields[page]', 'body');
  $this
    ->assertSession()
    ->optionExists('fields[page]', '-- None --');
  $options = $this
    ->xpath('//select[@name="fields[static_page]"]/option');
  $this
    ->assertCount(3, $options);
  $this
    ->assertSession()
    ->optionExists('fields[static_page]', 'body');
  $this
    ->assertSession()
    ->optionExists('fields[static_page]', 'static_page_field');
  $this
    ->assertSession()
    ->optionExists('fields[static_page]', '-- None --');
  $edit = [
    'fields[article]' => '',
    'fields[page]' => '',
    'fields[static_page]' => 'static_page_field',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration');
}