You are here

protected function LingotekHttpUnitTest::setUp in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.1.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  2. 3.2.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  3. 3.3.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  4. 3.4.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  5. 3.5.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  6. 3.6.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  7. 3.7.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  8. 3.8.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()

Overrides UnitTestCase::setUp

File

tests/src/Unit/Remote/LingotekHttpUnitTest.php, line 52

Class

LingotekHttpUnitTest
@coversDefaultClass \Drupal\lingotek\Remote\LingotekHttp @group lingotek @preserveGlobalState disabled @requires PHPUnit > 8 We depend on MockBuilder::addMethods() which was introduced in PHPUnit 8.

Namespace

Drupal\Tests\lingotek\Unit\Remote

Code

protected function setUp() : void {
  $this->httpClient = $this
    ->getMockBuilder(ClientInterface::class)
    ->addMethods([
    'get',
    'post',
    'patch',
    'delete',
  ])
    ->getMockForAbstractClass();
  $this->config = $this
    ->getMockBuilder(Config::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->accountConfig = $this
    ->getMockBuilder(Config::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->accountConfig
    ->expects($this
    ->any())
    ->method('get')
    ->will($this
    ->returnValueMap([
    [
      'host',
      'http://example.com',
    ],
    [
      'access_token',
      'the_token',
    ],
  ]));
  $this->configFactory = $this
    ->createMock(ConfigFactoryInterface::class);
  $this->configFactory
    ->expects($this
    ->any())
    ->method('get')
    ->withConsecutive([
    'lingotek.settings',
  ], [
    'lingotek.account',
  ])
    ->willReturnOnConsecutiveCalls($this->config, $this->accountConfig);
  $this->lingotekHttp = new LingotekHttp($this->httpClient, $this->configFactory);
}