You are here

public function UniqueFieldAjaxTest::testUniqueTitleCustomMessageWithLabelToken in Unique field ajax 2.x

Tests unique title custom message with an added label token.

Throws

\Drupal\Core\Entity\EntityStorageException

\Behat\Mink\Exception\ResponseTextException

File

tests/src/Functional/UniqueFieldAjaxTest.php, line 240

Class

UniqueFieldAjaxTest
Test the field permissions report page.

Namespace

Drupal\Tests\unique_field_ajax\Functional

Code

public function testUniqueTitleCustomMessageWithLabelToken() {

  // Create a random sentence including the label token.
  $msg = $this
    ->createRandomData('sentence');
  $msg .= " Here is my title label: %label ";
  $msg .= $this
    ->createRandomData('sentence');

  // Enable the unique and set a the custom message then create a basic node.
  $this
    ->updateThirdPartyEntitySetting('unique', TRUE);
  $this
    ->updateThirdPartyEntitySetting('message', $msg);
  $edit = $this
    ->createBasicUpdateData();
  $this
    ->itCanSaveField($edit);

  // Try to create again this time expect the custom message to be displayed.
  $msg = str_replace('%label', "title", $msg);
  $this
    ->itCannotSaveField($edit, $msg, NULL, 'title');
}