public function UniqueFieldAjaxTest::testUniqueTitleCustomMessageWithLinkToken in Unique field ajax 2.x
Tests unique title custom message with an added link token.
Throws
\Drupal\Core\Entity\EntityStorageException
\Behat\Mink\Exception\ResponseTextException
File
- tests/
src/ Functional/ UniqueFieldAjaxTest.php, line 263
Class
- UniqueFieldAjaxTest
- Test the field permissions report page.
Namespace
Drupal\Tests\unique_field_ajax\FunctionalCode
public function testUniqueTitleCustomMessageWithLinkToken() {
$num = 5;
// Create a random sentence including the label token.
$msg = $this
->createRandomData('sentence');
$msg .= " Here is my title link: %link";
// Enable the unique and set a the custom message then create a basic node.
$this
->updateThirdPartyEntitySetting('unique', TRUE);
$this
->updateThirdPartyEntitySetting('message', $msg);
// Create a random number of nodes saving the data for later.
$edits = [];
for ($i = 0; $i < $num; $i++) {
$edits[$i] = $this
->createBasicUpdateData();
$this
->itCanSaveField($edits[$i]);
}
// Pick a random edit and see if it tries to link to it.
$edit = $edits[array_rand($edits)];
$msg = str_replace('%link', $edit['title[0][value]'], $msg);
$this
->itCannotSaveField($edit, $msg, NULL, 'title');
}