public function ConditionalFieldTextfieldTest::testVisibleValueWidget in Conditional Fields 8
Same name and namespace in other branches
- 4.x tests/src/FunctionalJavascript/ConditionalFieldTextfieldTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldTextfieldTest::testVisibleValueWidget()
The target field is Visible when the control field has value from Widget.
Overrides ConditionalFieldValueInterface::testVisibleValueWidget
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldTextfieldTest.php, line 86
Class
- ConditionalFieldTextfieldTest
- Test Conditional Fields Text Handler.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueWidget() {
$this
->baseTestSteps();
// Visit a ConditionalFields configuration page for Content bundles.
$this
->createCondition($this->targetFieldName, 'field_' . $this->fieldName, 'visible', 'value');
// Set up conditions.
$text = $this
->getRandomGenerator()
->word(8);
$data = [
'condition' => 'value',
'values_set' => ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET,
'field_' . $this->fieldName . '[0][value]' => $text,
'grouping' => 'AND',
'state' => 'visible',
'effect' => 'show',
];
$this
->submitForm($data, 'Save settings');
// Check if that configuration is saved.
$this
->drupalGet('admin/structure/types/manage/article/conditionals');
$this
->assertSession()
->pageTextContains($this->targetFieldName . ' ' . 'field_' . $this->fieldName . ' 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($this->targetFieldWrapp, 0, '01. Article Body field is visible');
$this
->changeField($this->fieldSelector, $text);
$this
->waitUntilVisible($this->targetFieldWrapp, 50, '02. Article Body field is not visible');
// Change a select value set to hide the body again.
$this
->changeField($this->fieldSelector, $text . 'a');
$this
->waitUntilHidden($this->targetFieldWrapp, 50, '03. Article Body field is visible');
}