public function ConditionalFieldCheckboxesTest::testVisibleValueRegExp in Conditional Fields 4.x
Same name and namespace in other branches
- 8 tests/src/FunctionalJavascript/ConditionalFieldCheckboxesTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldCheckboxesTest::testVisibleValueRegExp()
Target field is Visible when the control field has value from regex.
Overrides ConditionalFieldValueInterface::testVisibleValueRegExp
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldCheckboxesTest.php, line 125
Class
- ConditionalFieldCheckboxesTest
- Test Conditional Fields Checkboxes Plugin.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueRegExp() {
$this
->baseTestSteps();
// Visit a ConditionalFields configuration page for Content bundles.
$this
->createCondition('body', 'field_' . $this->taxonomyName, 'visible', 'value');
// Change a condition's values set and the value.
$this
->changeField('#edit-values-set', ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_REGEX);
// Random term id to check necessary values.
$term_id_1 = mt_rand(1, $this->termsCount);
do {
$term_id_2 = mt_rand(1, $this->termsCount);
} while ($term_id_2 == $term_id_1);
$this
->changeSelect('#edit-regex', "{$term_id_1}");
// Submit the form.
$this
->getSession()
->executeScript("jQuery('#conditional-field-edit-form').submit();");
// Check if that configuration is saved.
$this
->drupalGet('admin/structure/types/manage/article/conditionals');
$this
->assertSession()
->pageTextContains('body field_' . $this->taxonomyName . ' visible value');
// 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, '01. Article Body field is visible');
// Change a select value set to show the body.
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_1, $term_id_1);
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_2, $term_id_2);
$this
->waitUntilVisible('.field--name-body', 60, '02. Article Body field is not visible');
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_1);
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_2);
$this
->waitUntilHidden('.field--name-body', 60, '03. Article Body field is visible');
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_1, $term_id_1);
$this
->waitUntilVisible('.field--name-body', 60, '04. Article Body field is not visible');
}