EndPointByLocationTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zhangw
  5. * Date: 2017/7/17
  6. * Time: 下午4:57
  7. */
  8. include_once '../../Config.php';
  9. use PHPUnit\Framework\TestCase;
  10. class EndPointByLocationTest extends TestCase
  11. {
  12. /**
  13. * @var
  14. */
  15. private $locationService;
  16. /**
  17. * @var
  18. */
  19. private $clientProfile;
  20. private function initClient()
  21. {
  22. # 创建 DefaultAcsClient 实例并初始化
  23. $this->clientProfile = DefaultProfile::getProfile(
  24. "cn-shanghai", # 您的 Region ID
  25. "<your AK>", # 您的 Access Key ID
  26. "<your Secret>" # 您的 Access Key Secret
  27. );
  28. $this->locationService = new LocationService($this->clientProfile);
  29. }
  30. public function testFindProductDomain()
  31. {
  32. $this->initClient();
  33. $domain = $this->locationService->findProductDomain("cn-shanghai", "apigateway", "openAPI", "CloudAPI");
  34. $this->assertEquals("apigateway.cn-shanghai.aliyuncs.com", $domain);
  35. }
  36. public function testFindProductDomainWithAddEndPoint()
  37. {
  38. DefaultProfile::addEndpoint("cn-shanghai", "cn-shanghai", "CloudAPI", "apigateway.cn-shanghai123.aliyuncs.com");
  39. $this->initClient();
  40. $domain = $this->locationService->findProductDomain("cn-shanghai", "apigateway", "openAPI", "CloudAPI");
  41. $this->assertEquals("apigateway.cn-shanghai123.aliyuncs.com", $domain);
  42. }
  43. }