You are here

public function LinkValidationApiTest::testInvalidExternalLinks in Link 7

Check Invalid External Links.

File

tests/LinkValidationApiTest.test, line 243
Validate the link_validate_url() validation API.

Class

LinkValidationApiTest
Validate the link_validate_url() validation API.

Code

public function testInvalidExternalLinks() {
  $links = array(
    'http://www.ex ample.com/',
    // Bad ip!
    'http://25.0.0/',
    'http://4827.0.0.2/',
    // ß not allowed in domain names!
    'http://www.testß.com/',
    // Bad TLD.
    'http://.www.foo.bar./',
    // Domains can't have sections starting with a dash.
    // 'http://www.-fudge.com/',
    'http://example.com/index.php?page=this\\that',
    'example@example.com',
  );
  foreach ($links as $link) {
    $valid = link_validate_url($link);
    $this
      ->assertEqual(FALSE, $valid, 'Testing that ' . $link . ' is not a valid link.');
  }
}