function AnnounceFeedTestRelevantVersion::testIsRelevantItem

Test for validating the announcements_feed_is_relevant_item function.

File

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

Class

AnnounceFeedTestRelevantVersion
Unit test for version compatibility functions.

Code

public function testIsRelevantItem() {
    $version_strings = array(
        array(
            '^7',
            TRUE,
        ),
        // TRUE only if Drupal version is exactly 7.0.
array(
            '=7.0',
            FALSE,
        ),
        array(
            '>=7',
            TRUE,
        ),
        array(
            '^7 || ^8 || ^9',
            TRUE,
        ),
        array(
            '>=7.52',
            TRUE,
        ),
        array(
            '^7.1 || ^8 || ^9',
            TRUE,
        ),
        // TRUE only if Drupal version is exactly 7.9999.
array(
            '=7.9999',
            FALSE,
        ),
        array(
            '^8 || ^9',
            FALSE,
        ),
        array(
            '>8',
            FALSE,
        ),
        array(
            '>=8.1',
            FALSE,
        ),
        array(
            '^8 || ^9 || ^10',
            FALSE,
        ),
    );
    foreach ($version_strings as $strings) {
        $result = announcements_feed_is_relevant_item($strings[0]);
        $this->assertEqual($strings[1], $result, 'Returned ' . ($strings[1] ? 'TRUE' : 'FALSE'));
    }
}

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