You are here

AuthApiTest.php in TMGMT Translator Smartling 8.2

Namespace

Smartling\Tests

File

vendor/smartling/api-sdk-php/tests/unit/AuthApiTest.php
View source
<?php

namespace Smartling\Tests;

use Smartling\AuthApi\AuthTokenProvider;
use Smartling\Tests\Unit\ApiTestAbstract;

/**
 * Test class for Smartling\AuthApi\AuthTokenProvider.
 */
class AuthApiTest extends ApiTestAbstract {

  /**
   * Sets up the fixture, for example, opens a network connection.
   * This method is called before a test is executed.
   */
  protected function setUp() {
    parent::setUp();
    $this
      ->prepareAuthApiMock();
  }
  private function prepareAuthApiMock() {
    $this->object = $this
      ->getMockBuilder('Smartling\\AuthApi\\AuthTokenProvider')
      ->setMethods(NULL)
      ->setConstructorArgs([
      $this->userIdentifier,
      $this->secretKey,
      $this->client,
    ])
      ->getMock();
  }

  /**
   * Test auth method.
   */
  public function testAuthenticate() {
    $endpointUrl = vsprintf('%s/authenticate', [
      AuthTokenProvider::ENDPOINT_URL,
    ]);
    $this->client
      ->expects(self::once())
      ->method('request')
      ->with('post', $endpointUrl, [
      'headers' => [
        'Accept' => 'application/json',
      ],
      'exceptions' => false,
      'json' => [
        'userIdentifier' => 'SomeUserIdentifier',
        'userSecret' => 'SomeSecretKey',
      ],
    ])
      ->willReturn($this->responseMock);
    $this
      ->invokeMethod($this->object, 'authenticate');
  }

}

Classes