public function ConditionalFieldSelectMultipleTest::testVisibleValueWidget in Conditional Fields 8
Same name and namespace in other branches
- 4.x tests/src/FunctionalJavascript/ConditionalFieldSelectMultipleTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldSelectMultipleTest::testVisibleValueWidget()
The target field is Visible when the control field has value from Widget.
Overrides ConditionalFieldValueInterface::testVisibleValueWidget
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldSelectMultipleTest.php, line 103
Class
- ConditionalFieldSelectMultipleTest
- Test Conditional Fields SelectMultiple Plugin.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueWidget() {
$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_WIDGET,
'field_' . $this->fieldName . '[]' => [
0,
1,
],
'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 to show the body.
$this
->changeField($this->fieldSelector, [
0,
1,
]);
$this
->createScreenshot($this->screenshotPath . '06-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 . '07-body-invisible-when-controlled-field-has-no-value-again.png');
$this
->waitUntilHidden('.field--name-body', 50, 'Article Body field is visible');
}