function AnnounceFeedTestValidateUrl::testValidateUrl

Test for validating the announcements_feed_validate_url function.

File

modules/announcements_feed/tests/announce_feed_test.test, line 138

Class

AnnounceFeedTestValidateUrl
Unit test for validate URL functions.

Code

public function testValidateUrl() {
    $urls = array(
        array(
            'https://www.drupal.org',
            TRUE,
        ),
        array(
            'https://drupal.org',
            TRUE,
        ),
        array(
            'https://api.drupal.org',
            TRUE,
        ),
        array(
            'https://a.drupal.org',
            TRUE,
        ),
        array(
            'https://123.drupal.org',
            TRUE,
        ),
        array(
            'https://api-new.drupal.org',
            TRUE,
        ),
        array(
            'https://api_new.drupal.org',
            TRUE,
        ),
        array(
            'https://api-.drupal.org',
            TRUE,
        ),
        array(
            'https://www.example.org',
            FALSE,
        ),
        array(
            'https://example.org',
            FALSE,
        ),
        array(
            'https://api.example.org/project/announce',
            FALSE,
        ),
        array(
            'https://-api.drupal.org',
            FALSE,
        ),
        array(
            'https://a.example.org/project/announce',
            FALSE,
        ),
        array(
            'https://test.drupaal.com',
            FALSE,
        ),
        array(
            'https://api.drupal.org.example.com',
            FALSE,
        ),
        array(
            'https://example.org/drupal.org',
            FALSE,
        ),
    );
    foreach ($urls as $url) {
        $result = announcements_feed_validate_url($url[0]);
        $this->assertEqual($url[1], $result, 'Returned ' . ($url[1] ? 'TRUE' : 'FALSE'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.