public function ConditionalFieldTextfieldTest::testVisibleValueRegExp in Conditional Fields 8
Same name and namespace in other branches
- 4.x tests/src/FunctionalJavascript/ConditionalFieldTextfieldTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldTextfieldTest::testVisibleValueRegExp()
The target field is Visible when the control field has value from Regular expression.
Overrides ConditionalFieldValueInterface::testVisibleValueRegExp
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldTextfieldTest.php, line 128
Class
- ConditionalFieldTextfieldTest
- Test Conditional Fields Text Handler.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueRegExp() {
$this
->baseTestSteps();
$this
->createCondition($this->targetFieldName, 'field_' . $this->fieldName, 'visible', 'value');
$data = [
'condition' => 'value',
'values_set' => ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_REGEX,
'regex' => '.*data\\=[\\d]+.*',
'grouping' => 'AND',
'state' => 'visible',
'effect' => 'show',
];
$text_without_expresion = 'The field in not empty';
$text_with_expresion = 'The field has data=2 text';
$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');
$this
->drupalGet('node/add/article');
$this
->assertSession()
->elementExists('css', $this->targetFieldWrapp);
$this
->waitUntilHidden($this->targetFieldWrapp, 0, '01. Article Body field is visible');
$this
->changeField($this->fieldSelector, $text_without_expresion);
$this
->waitUntilHidden($this->targetFieldWrapp, 50, '02. Article Body field is visible');
$this
->changeField($this->fieldSelector, $text_with_expresion);
$this
->waitUntilVisible($this->targetFieldWrapp, 50, '03. Article Body field is not visible');
}