public function ConditionalFieldLanguageSelectTest::testVisibleValueNot in Conditional Fields 4.x
Same name and namespace in other branches
- 8 tests/src/FunctionalJavascript/ConditionalFieldLanguageSelectTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldLanguageSelectTest::testVisibleValueNot()
Target field is Visible when control field has value with NOT condition.
Overrides ConditionalFieldValueInterface::testVisibleValueNot
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldLanguageSelectTest.php, line 293
Class
- ConditionalFieldLanguageSelectTest
- Test Conditional Fields Language Select Plugin.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueNot() {
$this
->baseTestSteps();
// Visit a ConditionalFields configuration page for Content bundles.
$this
->createCondition('body', $this->fieldName, 'visible', 'value');
$this
->createScreenshot($this->screenshotPath . '01-language-select-add-filed-conditions.png');
// Set up conditions.
$data = [
'condition' => 'value',
'values_set' => ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_NOT,
"values" => implode("\r\n", $this->langcodes),
'grouping' => 'AND',
'state' => 'visible',
'effect' => 'show',
];
$this
->submitForm($data, 'Save settings');
$this
->createScreenshot($this->screenshotPath . '02-language-select-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-language-select-submit-list-options-filed-conditions.png');
$this
->assertSession()
->pageTextContains('body ' . $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 visible.
$this
->createScreenshot($this->screenshotPath . '04-language-select-body-visible-when-controlled-field-has-default-value.png');
$this
->waitUntilVisible('.field--name-body', 50, '01. Article Body field is not visible');
// Change a select value set that should not show the body.
$this
->changeField($this->fieldSelector, $this->langcodes[0]);
$this
->createScreenshot($this->screenshotPath . '05-language-select-body-invisible-when-controlled-field-has-wrong-value.png');
$this
->waitUntilHidden('.field--name-body', 50, '02. Article Body field is visible');
// Change a select value set to show the body.
$this
->changeField($this->fieldSelector, $this->defaultLanguage);
$this
->createScreenshot($this->screenshotPath . '06-language-select-body-visible-when-controlled-field-has-value.png');
$this
->waitUntilVisible('.field--name-body', 50, '03. Article Body field is not visible');
// Change a select value set to hide the body again.
$this
->changeField($this->fieldSelector, $this->langcodes[1]);
$this
->createScreenshot($this->screenshotPath . '07-language-select-body-invisible-when-controlled-field-has-wrong-value-again.png');
$this
->waitUntilHidden('.field--name-body', 50, '04. Article Body field is visible');
}