function BrowserTestBaseTest::testGetHttpClient

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::testGetHttpClient()
  2. 10 core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::testGetHttpClient()
  3. 11.x core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::testGetHttpClient()

@covers ::getHttpClient

File

core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php, line 40

Class

BrowserTestBaseTest
@coversDefaultClass \Drupal\Tests\BrowserTestBase @group Test

Namespace

Drupal\Tests\Core\Test

Code

public function testGetHttpClient() {
    // Our stand-in for the Guzzle client object.
    $expected = new \stdClass();
    $browserkit_client = $this->getMockBuilder(DrupalTestBrowser::class)
        ->onlyMethods([
        'getClient',
    ])
        ->getMockForAbstractClass();
    $browserkit_client->expects($this->once())
        ->method('getClient')
        ->willReturn($expected);
    // Because the driver is a BrowserKitDriver, we'll get back a client.
    $driver = new BrowserKitDriver($browserkit_client);
    $btb = $this->mockBrowserTestBaseWithDriver($driver);
    $ref_gethttpclient = new \ReflectionMethod($btb, 'getHttpClient');
    $ref_gethttpclient->setAccessible(TRUE);
    $this->assertSame(get_class($expected), get_class($ref_gethttpclient->invoke($btb)));
}

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