public function ConditionalFieldTextfieldTest::testVisibleValueAnd in Conditional Fields 4.x
Same name and namespace in other branches
- 8 tests/src/FunctionalJavascript/ConditionalFieldTextfieldTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldTextfieldTest::testVisibleValueAnd()
Target field is Visible when control field has value with AND condition.
Overrides ConditionalFieldValueInterface::testVisibleValueAnd
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldTextfieldTest.php, line 163
Class
- ConditionalFieldTextfieldTest
- Test Conditional Fields Text Handler.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueAnd() {
$this
->baseTestSteps();
$this
->createCondition($this->targetFieldName, 'field_' . $this->fieldName, 'visible', 'value');
$text_1 = $this
->getRandomGenerator()
->word(7);
$text_2 = $this
->getRandomGenerator()
->word(7);
$data = [
'condition' => 'value',
'values_set' => ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_AND,
'values' => implode("\r\n", [
$text_1,
$text_2,
]),
'grouping' => 'AND',
'state' => 'visible',
'effect' => 'show',
];
$this
->submitForm($data, 'Save settings');
$this
->drupalGet('node/add/article');
$this
->assertSession()
->elementExists('css', $this->targetFieldWrapp);
$text_false = implode(' ', [
$text_1,
$text_2,
]);
$this
->waitUntilHidden($this->targetFieldWrapp, 0, '01. Article Body field is visible');
$this
->changeField($this->fieldSelector, $text_false);
$this
->waitUntilHidden($this->targetFieldWrapp, 50, '02. Article Body field is visible');
$this
->changeField($this->fieldSelector, $text_1);
$this
->waitUntilHidden($this->targetFieldWrapp, 50, '03. Article Body field is visible');
// Change a value value to hide the body again.
$this
->changeField($this->fieldSelector, '');
$this
->waitUntilHidden($this->targetFieldWrapp, 50, '04. Article Body field is visible');
}