public function ConditionalFieldSelectMultipleTest::testVisibleValueAnd in Conditional Fields 8
Same name and namespace in other branches
- 4.x tests/src/FunctionalJavascript/ConditionalFieldSelectMultipleTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldSelectMultipleTest::testVisibleValueAnd()
The target field is Visible when the control field has value with AND condition.
Overrides ConditionalFieldValueInterface::testVisibleValueAnd
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldSelectMultipleTest.php, line 217
Class
- ConditionalFieldSelectMultipleTest
- Test Conditional Fields SelectMultiple Plugin.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueAnd() {
$this
->baseTestSteps();
// Visit a ConditionalFields configuration page for Content bundles.
$this
->createCondition('body', 'field_' . $this->fieldName, 'visible', 'value');
$this
->createScreenshot($this->screenshotPath . '01-add-list-options-filed-conditions.png');
// Set up conditions.
$data = [
'condition' => 'value',
'values_set' => ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_AND,
'values' => "0\r\n1",
'grouping' => 'AND',
'state' => 'visible',
'effect' => 'show',
];
$this
->submitForm($data, 'Save settings');
$this
->createScreenshot($this->screenshotPath . '02-post-add-list-options-filed-conditions.png');
// Check if that configuration is saved.
$this
->drupalGet('admin/structure/types/manage/article/conditionals');
$this
->createScreenshot($this->screenshotPath . '03-submit-list-options-filed-conditions.png');
$this
->assertSession()
->pageTextContains('body ' . '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
->createScreenshot($this->screenshotPath . '04-body-invisible-when-controlled-field-has-no-value.png');
$this
->waitUntilHidden('.field--name-body', 50, 'Article Body field is visible');
// Change a select value set that should not show the body.
$this
->changeField($this->fieldSelector, [
0,
]);
$this
->createScreenshot($this->screenshotPath . '05-body-invisible-when-controlled-field-has-wrong-value.png');
$this
->waitUntilHidden('.field--name-body', 50, 'Article Body field is visible');
// Change a select value set that should not show the body.
$this
->changeField($this->fieldSelector, [
0,
3,
]);
$this
->createScreenshot($this->screenshotPath . '06-body-invisible-when-controlled-field-has-wrong-value.png');
$this
->waitUntilHidden('.field--name-body', 50, 'Article Body field is visible');
// Change a select value set to show the body.
$this
->changeField($this->fieldSelector, [
0,
1,
]);
$this
->createScreenshot($this->screenshotPath . '07-body-visible-when-controlled-field-has-value.png');
$this
->waitUntilVisible('.field--name-body', 50, 'Article Body field is not visible');
// Change a select value set to hide the body again.
$this
->changeField($this->fieldSelector, [
'_none',
]);
$this
->createScreenshot($this->screenshotPath . '08-body-invisible-when-controlled-field-has-no-value-again.png');
$this
->waitUntilHidden('.field--name-body', 50, 'Article Body field is visible');
}