function BootstrapTrustedHostsTestCase::testTrustedHosts

Tests hostname validation.

See also

drupal_check_trusted_hosts()

File

modules/simpletest/tests/bootstrap.test, line 985

Class

BootstrapTrustedHostsTestCase
Test the trusted HTTP host configuration.

Code

function testTrustedHosts() {
    $trusted_host_patterns = array(
        '^example\\.com$',
        '^.+\\.example\\.com$',
        '^example\\.org',
        '^.+\\.example\\.org',
    );
    foreach ($this->providerTestTrustedHosts() as $data) {
        $test = array_combine(array(
            'host',
            'message',
            'expected',
        ), $data);
        $valid_host = drupal_check_trusted_hosts($test['host'], $trusted_host_patterns);
        $this->assertEqual($test['expected'], $valid_host, $test['message']);
    }
}

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