You are here

class AuthApiTest in TMGMT Translator Smartling 8.2

Same name in this branch
  1. 8.2 api-sdk-php/tests/unit/AuthApiTest.php \Smartling\Tests\AuthApiTest
  2. 8.2 vendor/smartling/api-sdk-php/tests/unit/AuthApiTest.php \Smartling\Tests\AuthApiTest
Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/tests/unit/AuthApiTest.php \Smartling\Tests\AuthApiTest
  2. 8.3 vendor/smartling/api-sdk-php/tests/unit/AuthApiTest.php \Smartling\Tests\AuthApiTest

Test class for Smartling\AuthApi\AuthTokenProvider.

Hierarchy

  • class \Smartling\Tests\AuthApiTest extends \Smartling\Tests\Unit\ApiTestAbstract

Expanded class hierarchy of AuthApiTest

File

vendor/smartling/api-sdk-php/tests/unit/AuthApiTest.php, line 11

Namespace

Smartling\Tests
View source
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');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthApiTest::prepareAuthApiMock private function
AuthApiTest::setUp protected function Sets up the fixture, for example, opens a network connection. This method is called before a test is executed.
AuthApiTest::testAuthenticate public function Test auth method.