You are here

function SoundCloudWidgetValidationTest::testSoundCloudUrlInvalid in SoundCloud field 8

Test an invalid URLs or strings

File

src/Tests/SoundCloudWidgetValidationTest.php, line 77

Class

SoundCloudWidgetValidationTest
Test case for custom time field

Namespace

Drupal\soundcloudfield\Tests

Code

function testSoundCloudUrlInvalid() {
  $field = $this
    ->getField();

  // Display creation form.
  $this
    ->drupalGet('entity_test/add');
  $this
    ->assertFieldByName("{$this->fieldName}[0][url]", '', 'SoundCloud URL');
  $this
    ->assertRaw('value=""');

  // Create a path alias.
  \Drupal::service('path.alias_storage')
    ->save('/admin', '/a/path/alias');

  // Create a node to test the link widget.
  $node = $this
    ->drupalCreateNode();
  $validationError = 'Please insert a valid SoundCloud url.';
  $invalidEntries = [
    'only a string' => $validationError,
    'https://lmgtfy.com/' => $validationError,
  ];
  $this
    ->assertInvalidEntries($invalidEntries);
}