* Tests link field URL validation.
*/
public function testURLValidation() {
- $field_name = Unicode::strtolower($this->randomMachineName());
+ $field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'/?example=llama' => '<front>?example=llama',
'/#example' => '<front>#example',
+ // Trailing spaces should be ignored.
+ '/ ' => '<front>',
+ '/path with spaces ' => '/path with spaces',
+
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
'<front>' => '<front>',
preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
- $this->assertRaw($string);
+ $this->assertRaw('"' . $string . '"');
}
}
* Tests the link title settings of a link field.
*/
public function testLinkTitle() {
- $field_name = Unicode::strtolower($this->randomMachineName());
+ $field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
$this->assertRaw('placeholder="Enter the text for this link"');
$this->assertFieldByName("{$field_name}[0][title]", '', 'Link text field found.');
+ if ($title_setting === DRUPAL_OPTIONAL) {
+ // Verify that the URL is required, if the link text is non-empty.
+ $edit = [
+ "{$field_name}[0][title]" => 'Example',
+ ];
+ $this->drupalPostForm(NULL, $edit, t('Save'));
+ $this->assertText(t('The URL field is required when the @title field is specified.', ['@title' => t('Link text')]));
+ }
if ($title_setting === DRUPAL_REQUIRED) {
// Verify that the link text is required, if the URL is non-empty.
$edit = [
* Tests the default 'link' formatter.
*/
public function testLinkFormatter() {
- $field_name = Unicode::strtolower($this->randomMachineName());
+ $field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
* merged, since they involve different configuration and output.
*/
public function testLinkSeparateFormatter() {
- $field_name = Unicode::strtolower($this->randomMachineName());
+ $field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
public function testLinkTypeOnLinkWidget() {
$link_type = LinkItemInterface::LINK_EXTERNAL;
- $field_name = Unicode::strtolower($this->randomMachineName());
+ $field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
$this->assertEqual($form[$field_name]['widget'][0]['uri']['#link_type'], $link_type);
}
-
/**
* Tests editing a link to a non-node entity.
*/