public function ConditionalFieldLinkFieldTest::testVisibleValueXor in Conditional Fields 4.x
Same name and namespace in other branches
- 8 tests/src/FunctionalJavascript/ConditionalFieldLinkFieldTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldLinkFieldTest::testVisibleValueXor()
Target field is Visible when control field has value with XOR condition.
Overrides ConditionalFieldValueInterface::testVisibleValueXor
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldLinkFieldTest.php, line 381
Class
- ConditionalFieldLinkFieldTest
- Test Conditional Fields Link field plugin.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testVisibleValueXor() {
$this
->baseTestSteps();
// Visit a ConditionalFields configuration page for Content bundles.
$this
->createCondition('body', $this->fieldName, 'visible', 'value');
$this
->createScreenshot($this->screenshotPath . '01-testFieldLinkVisibleValueNot.png');
// Set up conditions.
$urls = [
'node/add',
'node/1',
];
$data = [
'condition' => 'value',
'values_set' => ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_XOR,
'values' => implode("\r\n", $urls),
'grouping' => 'AND',
'state' => 'visible',
'effect' => 'show',
];
$this
->submitForm($data, 'Save settings');
$this
->createScreenshot($this->screenshotPath . '02-testFieldLinkVisibleValueNot.png');
// Check if that configuration is saved.
$this
->drupalGet('admin/structure/types/manage/article/conditionals');
$this
->createScreenshot($this->screenshotPath . '03-testFieldLinkVisibleValueNot.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 not visible.
$this
->createScreenshot($this->screenshotPath . '04-testFieldLinkVisibleValueNot.png');
$this
->waitUntilHidden('.field--name-body', 50, '01. Article Body field is visible');
// Change a link that should be show the body.
$this
->changeField($this->fieldSelector, $urls[0]);
$this
->createScreenshot($this->screenshotPath . '05-testFieldLinkVisibleValueNot.png');
$this
->waitUntilVisible('.field--name-body', 50, '02. Article Body field is not visible');
// Change a link that should be show the body again.
$this
->changeField($this->fieldSelector, $urls[1]);
$this
->createScreenshot($this->screenshotPath . '06-testFieldLinkVisibleValueNot.png');
$this
->waitUntilVisible('.field--name-body', 50, '03. Article Body field is not visible');
// Change a link that should not show the body.
$this
->changeField($this->fieldSelector, "http://example.com");
$this
->createScreenshot($this->screenshotPath . '06-testFieldLinkVisibleValueNot.png');
$this
->waitUntilHidden('.field--name-body', 50, '03. Article Body field is visible');
// Change a link value to hide the body.
$this
->changeField($this->fieldSelector, '');
$this
->createScreenshot($this->screenshotPath . '08-testFieldLinkVisibleValueNot.png');
$this
->waitUntilHidden('.field--name-body', 50, '04. Article Body field is visible');
}