BearerTokenClientTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Clients;
  3. use PHPUnit\Framework\TestCase;
  4. use AlibabaCloud\Client\Exception\ClientException;
  5. use AlibabaCloud\Client\Exception\ServerException;
  6. use AlibabaCloud\Client\Clients\BearerTokenClient;
  7. use AlibabaCloud\Client\Signature\BearerTokenSignature;
  8. use AlibabaCloud\Client\Credentials\BearerTokenCredential;
  9. /**
  10. * Class BearerTokenClientTest
  11. *
  12. * @package AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Clients
  13. */
  14. class BearerTokenClientTest extends TestCase
  15. {
  16. /**
  17. * @return BearerTokenClient
  18. * @throws ClientException
  19. */
  20. public function testConstruct()
  21. {
  22. // Setup
  23. $bearerToken = 'bearerToken';
  24. // Test
  25. $client = new BearerTokenClient($bearerToken);
  26. // Assert
  27. self::assertEquals($bearerToken, $client->getCredential()->getBearerToken());
  28. self::assertInstanceOf(BearerTokenSignature::class, $client->getSignature());
  29. return $client;
  30. }
  31. /**
  32. * @depends testConstruct
  33. *
  34. * @param BearerTokenClient $client
  35. *
  36. * @throws ClientException
  37. * @throws ServerException
  38. */
  39. public function testGetSessionCredential(BearerTokenClient $client)
  40. {
  41. self::assertInstanceOf(BearerTokenCredential::class, $client->getSessionCredential());
  42. }
  43. }