public function ConditionalFieldRadiosTest::testVisibleValueXor in Conditional Fields 8
Same name and namespace in other branches
- 4.x tests/src/FunctionalJavascript/ConditionalFieldRadiosTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldRadiosTest::testVisibleValueXor()
The target field is Visible when the control field has value with XOR condition.
Overrides ConditionalFieldValueInterface::testVisibleValueXor
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldRadiosTest.php, line 321
Class
- ConditionalFieldRadiosTest
- Test Conditional Fields States.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueXor() {
$this
->baseTestSteps();
// Visit a ConditionalFields configuration page for `Article` Content type.
$this
->createCondition('body', 'field_' . $this->taxonomyName, 'visible', 'value');
// Change a condition's values set and the value.
$term_id_1 = mt_rand(1, $this->termsCount);
do {
$term_id_2 = mt_rand(1, $this->termsCount);
} while ($term_id_2 == $term_id_1);
$data = [
'condition' => 'value',
'values_set' => ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_XOR,
'values' => "{$term_id_1}\r\n{$term_id_2}",
'grouping' => 'AND',
'state' => 'visible',
'effect' => 'show',
];
$this
->submitForm($data, 'Save settings');
// Check if that configuration is saved.
$this
->drupalGet('admin/structure/conditional_fields/node/article');
$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
->waitUntilVisible('.field--name-body', 50, '02. Article Body field is not visible');
// Change a select value set to hide the body again.
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_1);
$this
->waitUntilHidden('.field--name-body', 50, '03. Article Body field is visible');
// Change a select value set to show the body.
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_2, $term_id_2);
$this
->waitUntilVisible('.field--name-body', 50, '04. Article Body field is not visible');
// Change a select value set to hide the body again.
$this
->changeSelect('#edit-field-' . $this->taxonomyName . '-' . $term_id_2);
$this
->waitUntilHidden('.field--name-body', 50, '05. Article Body field is visible');
// Change a select value set to hide 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', 50, '04. Article Body field is not visible');
}