You are here

protected function BrowserTestBaseTest::mockBrowserTestBaseWithDriver in Drupal 8

Same name and namespace in other branches
  1. 9 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()
    ->setMethods([
    'getDriver',
  ])
    ->getMock();
  $session
    ->expects($this
    ->once())
    ->method('getDriver')
    ->willReturn($driver);
  $btb = $this
    ->getMockBuilder(BrowserTestBase::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'getSession',
  ])
    ->getMockForAbstractClass();
  $btb
    ->expects($this
    ->once())
    ->method('getSession')
    ->willReturn($session);
  return $btb;
}