You are here

public function ConfigPageTest::testRequireOnPublishToggles in Require on Publish 8

Test that the 'Required on Publish' field toggle works.

'Required on Publish' and 'Required' should not be able to both be checked at the same time. This test ensures that the Javascript that enforces that is working.

File

tests/src/FunctionalJavascript/ConfigPageTest.php, line 100

Class

ConfigPageTest
Tests the 'Require on Publish' functionality on field config pages.

Namespace

Drupal\Tests\require_on_publish\FunctionalJavascript

Code

public function testRequireOnPublishToggles() {
  $this
    ->logIn();
  $this
    ->getSession()
    ->getPage()
    ->fillField('require_on_publish', 1);

  // Verify 'Required' is empty.
  $required = $this
    ->getSession()
    ->getPage()
    ->findField('required')
    ->getValue();
  $this
    ->assertEquals(0, $required);

  // Click 'Required'.
  $this
    ->getSession()
    ->getPage()
    ->fillField('required', 1);

  // Verify 'Required on Publish' is empty.
  $required = $this
    ->getSession()
    ->getPage()
    ->findField('require_on_publish')
    ->getValue();
  $this
    ->assertEquals(0, $required);
}