You are here

public function WebTestBaseTest::testGetAbsoluteUrl in Drupal 8

@dataProvider providerTestGetAbsoluteUrl

File

core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php, line 201

Class

WebTestBaseTest
@requires extension curl @coversDefaultClass \Drupal\simpletest\WebTestBase @group simpletest @group WebTestBase

Namespace

Drupal\Tests\simpletest\Unit

Code

public function testGetAbsoluteUrl($href, $expected_absolute_path) {
  $web_test = $this
    ->getMockBuilder('Drupal\\simpletest\\WebTestBase')
    ->disableOriginalConstructor()
    ->setMethods([
    'getUrl',
  ])
    ->getMock();
  $web_test
    ->expects($this
    ->any())
    ->method('getUrl')
    ->willReturn('http://example.com/drupal/current-path?foo=baz');
  $GLOBALS['base_url'] = 'http://example.com';
  $GLOBALS['base_path'] = 'drupal';
  $get_absolute_url_method = new \ReflectionMethod($web_test, 'getAbsoluteUrl');
  $get_absolute_url_method
    ->setAccessible(TRUE);
  $this
    ->assertSame($expected_absolute_path, $get_absolute_url_method
    ->invoke($web_test, $href));
  unset($GLOBALS['base_url'], $GLOBALS['base_path']);
}