EndPointByLocationTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. private $locationService;
  13. private $clientProfile;
  14. private function initClient()
  15. {
  16. # 创建 DefaultAcsClient 实例并初始化
  17. $this->clientProfile = DefaultProfile::getProfile(
  18. "cn-shanghai", # 您的 Region ID
  19. "<your AK>", # 您的 Access Key ID
  20. "<your Secret>" # 您的 Access Key Secret
  21. );
  22. $this->locationService = new LocationService($this->clientProfile);
  23. }
  24. public function testFindProductDomain()
  25. {
  26. $this->initClient();
  27. $domain = $this->locationService->findProductDomain("cn-shanghai", "apigateway", "openAPI", "CloudAPI");
  28. $this->assertEquals("apigateway.cn-shanghai.aliyuncs.com", $domain);
  29. }
  30. public function testFindProductDomainWithAddEndPoint()
  31. {
  32. DefaultProfile::addEndpoint("cn-shanghai", "cn-shanghai", "CloudAPI", "apigateway.cn-shanghai123.aliyuncs.com");
  33. $this->initClient();
  34. $domain = $this->locationService->findProductDomain("cn-shanghai", "apigateway", "openAPI", "CloudAPI");
  35. $this->assertEquals("apigateway.cn-shanghai123.aliyuncs.com", $domain);
  36. }
  37. }