public function UniqueFieldAjaxTest::testUniqueFieldCustomMessageWithLabelToken in Unique field ajax 2.x
Tests unique field custom message with an added label token.
Throws
\Drupal\Core\Entity\EntityStorageException
\Behat\Mink\Exception\ResponseTextException
File
- tests/
src/ Functional/ UniqueFieldAjaxTest.php, line 153
Class
- UniqueFieldAjaxTest
- Test the field permissions report page.
Namespace
Drupal\Tests\unique_field_ajax\FunctionalCode
public function testUniqueFieldCustomMessageWithLabelToken() {
foreach ($this->fieldTypes as $field_type) {
$this
->createField($field_type['type'], $field_type['widget'], $field_type['settings']);
$field_name = $this->fieldStorage
->getName();
// Create a random sentence including the label token.
$msg = $this
->createRandomData('sentence');
$msg .= " Here is my field label: %label ";
$msg .= $this
->createRandomData('sentence');
// The unique and set a the custom message then create a basic node.
$this
->updateThirdPartyFieldSetting('unique', TRUE);
$this
->updateThirdPartyFieldSetting('message', $msg);
$edit = $this
->createUpdateFieldData($field_name, $field_type['value'], $field_type['effect']);
$this
->itCanSaveField($edit);
// Create again this time expect the custom message to be displayed.
$msg = str_replace('%label', $field_name . "_label", $msg);
$this
->itCannotSaveField($edit, $msg);
}
}