1 common.test CommonURLUnitTestCase::testBackdropGetBareDomain()

Test backdrop_get_bare_domain().

File

core/modules/simpletest/tests/common.test, line 328
Tests for common.inc functionality.

Class

CommonURLUnitTestCase
All URL testing that does not require a Backdrop bootstrap.

Code

function testBackdropGetBareDomain() {
  // Input => Expected Output.
  $tests = array(
    'http://www.example.com/path-to-page' => 'example.com',
    'http://example.com/path-to-page' => 'example.com',
    'http://beta.example.com/path-to-page' => 'example.com',
    'https://www.beta.example.co.uk/path-to-page' => 'example.co.uk',
    'http://example.co.uk/path-to-page' => 'example.co.uk',
    'http://beta.example.co.uk/path-to-page' => 'example.co.uk',
    '//example.co.uk/path-to-page' => 'example.co.uk',

    'example.co.uk' => 'example.co.uk',
    'example.com' => 'example.com',
    'beta.example.com' => 'example.com',
    'alpha.beta.example.com' => 'example.com',
    'bbc.co.uk' => 'bbc.co.uk',
    'foo.bbc.co.uk' => 'bbc.co.uk',
    'bar.foo.bbc.co.uk' => 'bbc.co.uk',
    'bar.foo.abc.com' => 'abc.com',
    'lb.cm' => 'lb.cm',
  );

  foreach ($tests as $input => $expected_output) {
    $this->assertIdentical($expected_output, backdrop_get_bare_domain($input));
  }
}