You are here

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

Same name and namespace in other branches
  1. 4.0.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  2. 3.1.x tests/src/Unit/Remote/LingotekHttpUnitTest.php \Drupal\Tests\lingotek\Unit\Remote\LingotekHttpUnitTest::setUp()
  3. 3.2.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 47

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->config
    ->expects($this
    ->any())
    ->method('get')
    ->will($this
    ->returnValueMap([
    [
      'account.host',
      'http://example.com',
    ],
    [
      'account.access_token',
      'the_token',
    ],
  ]));
  $this->configFactory = $this
    ->createMock(ConfigFactoryInterface::class);
  $this->configFactory
    ->expects($this
    ->any())
    ->method('get')
    ->with('lingotek.settings')
    ->will($this
    ->returnValue($this->config));
  $this->lingotekHttp = new LingotekHttp($this->httpClient, $this->configFactory);
}