function BrowserTestBaseTest::mockBrowserTestBaseWithDriver

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::mockBrowserTestBaseWithDriver()
  2. 10 core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::mockBrowserTestBaseWithDriver()
  3. 11.x core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::mockBrowserTestBaseWithDriver()
2 calls to BrowserTestBaseTest::mockBrowserTestBaseWithDriver()
BrowserTestBaseTest::testGetHttpClient in core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php
@covers ::getHttpClient
BrowserTestBaseTest::testGetHttpClientException in core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php
@covers ::getHttpClient

File

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

Class

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

Namespace

Drupal\Tests\Core\Test

Code

protected function mockBrowserTestBaseWithDriver($driver) {
    $session = $this->getMockBuilder(Session::class)
        ->disableOriginalConstructor()
        ->onlyMethods([
        'getDriver',
    ])
        ->getMock();
    $session->expects($this->any())
        ->method('getDriver')
        ->willReturn($driver);
    $btb = $this->getMockBuilder(BrowserTestBase::class)
        ->disableOriginalConstructor()
        ->onlyMethods([
        'getSession',
    ])
        ->getMockForAbstractClass();
    $btb->expects($this->any())
        ->method('getSession')
        ->willReturn($session);
    return $btb;
}

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