You are here

public function ConditionalFieldRadiosTest::testVisibleChecked in Conditional Fields 8

Same name and namespace in other branches
  1. 4.x tests/src/FunctionalJavascript/ConditionalFieldRadiosTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldRadiosTest::testVisibleChecked()

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

Overrides ConditionalFieldCheckedUncheckedInterface::testVisibleChecked

File

tests/src/FunctionalJavascript/ConditionalFieldRadiosTest.php, line 374

Class

ConditionalFieldRadiosTest
Test Conditional Fields States.

Namespace

Drupal\Tests\conditional_fields\FunctionalJavascript

Code

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

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

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

  // Visit Article Add form to check that conditions are applied.
  $this
    ->drupalGet('node/add/article');

  // Check that the field Body is not visible.
  $this
    ->waitUntilHidden('.field--name-body', 0, 'Article Body field is visible');
  for ($term_id = 1; $term_id < $this->termsCount; $term_id++) {

    // Change a select value set to show the body.
    $this
      ->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id, $term_id);
    $this
      ->waitUntilVisible('.field--name-body', 50, $term_id . '. Article Body field is not visible');

    //      $this->createScreenshot('sites/simpletest/scr1BodyVisTerm'.$term_id.'.jpg');
  }
}