You are here

public function ConditionalFieldCheckboxTest::testVisibleUnchecked in Conditional Fields 4.x

Same name and namespace in other branches
  1. 8 tests/src/FunctionalJavascript/ConditionalFieldCheckboxTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldCheckboxTest::testVisibleUnchecked()

The target field is Visible when the control field is Unchecked.

Overrides ConditionalFieldCheckedUncheckedInterface::testVisibleUnchecked

File

tests/src/FunctionalJavascript/ConditionalFieldCheckboxTest.php, line 43

Class

ConditionalFieldCheckboxTest
Test Conditional Fields Checkbox state.

Namespace

Drupal\Tests\conditional_fields\FunctionalJavascript

Code

public function testVisibleUnchecked() {
  $this
    ->baseTestSteps();

  // Visit a ConditionalFields configuration page for `Article` Content type.
  $this
    ->createCondition('body', 'promote', 'visible', '!checked');

  // Check that configuration is saved.
  $this
    ->drupalGet('admin/structure/conditional_fields/node/article');
  $this
    ->assertSession()
    ->pageTextContains('body promote visible !checked');

  // Visit Article Add form to check that conditions are applied.
  $this
    ->drupalGet('node/add/article');
  $this
    ->waitUntilHidden('.field--name-body', 10, '01. Article Body field is visible');
  $this
    ->changeSelect('#edit-promote-value', FALSE);
  $this
    ->waitUntilVisible('.field--name-body', 0, '02. Article Body field is not visible');
}