No Description

ZoneTest.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace Qiniu\Tests;
  3. use Qiniu;
  4. use Qiniu\Zone;
  5. class ZoneTest extends \PHPUnit_Framework_TestCase
  6. {
  7. protected $zone;
  8. protected $zoneHttps;
  9. protected $ak;
  10. protected $bucketName;
  11. protected $bucketNameBC;
  12. protected $bucketNameNA;
  13. protected $bucketNameFS;
  14. protected $bucketNameAS;
  15. protected function setUp()
  16. {
  17. global $bucketName;
  18. $this->bucketName = $bucketName;
  19. global $bucketNameBC;
  20. $this->bucketNameBC = $bucketNameBC;
  21. global $bucketNameNA;
  22. $this->bucketNameNA = $bucketNameNA;
  23. global $bucketNameFS;
  24. $this->bucketNameFS = $bucketNameFS;
  25. global $bucketNameAS;
  26. $this->bucketNameAS = $bucketNameAS;
  27. global $accessKey;
  28. $this->ak = $accessKey;
  29. $this->zone = new Zone();
  30. $this->zoneHttps = new Zone('https');
  31. }
  32. public function testUpHosts()
  33. {
  34. list($ret, $err) = Zone::queryZone($this->ak, 'fakebucket');
  35. $this->assertNull($ret);
  36. $this->assertNotNull($err);
  37. $zone = Zone::queryZone($this->ak, $this->bucketName);
  38. $this->assertContains('upload.qiniup.com', $zone->cdnUpHosts);
  39. $zone = Zone::queryZone($this->ak, $this->bucketNameBC);
  40. $this->assertContains('upload-z1.qiniup.com', $zone->cdnUpHosts);
  41. $zone = Zone::queryZone($this->ak, $this->bucketNameFS);
  42. $this->assertContains('upload-z2.qiniup.com', $zone->cdnUpHosts);
  43. $zone = Zone::queryZone($this->ak, $this->bucketNameNA);
  44. $this->assertContains('upload-na0.qiniup.com', $zone->cdnUpHosts);
  45. $zone = Zone::queryZone($this->ak, $this->bucketNameAS);
  46. $this->assertContains('upload-as0.qiniup.com', $zone->cdnUpHosts);
  47. }
  48. public function testIoHosts()
  49. {
  50. $zone = Zone::queryZone($this->ak, $this->bucketName);
  51. $this->assertEquals($zone->iovipHost, 'iovip.qbox.me');
  52. $zone = Zone::queryZone($this->ak, $this->bucketNameBC);
  53. $this->assertEquals($zone->iovipHost, 'iovip-z1.qbox.me');
  54. $zone = Zone::queryZone($this->ak, $this->bucketNameFS);
  55. $this->assertEquals($zone->iovipHost, 'iovip-z2.qbox.me');
  56. $zone = Zone::queryZone($this->ak, $this->bucketNameNA);
  57. $this->assertEquals($zone->iovipHost, 'iovip-na0.qbox.me');
  58. $zone = Zone::queryZone($this->ak, $this->bucketNameAS);
  59. $this->assertEquals($zone->iovipHost, 'iovip-as0.qbox.me');
  60. }
  61. public function testZonez0()
  62. {
  63. $zone = Zone::zonez0();
  64. $this->assertContains('upload.qiniup.com', $zone->cdnUpHosts);
  65. }
  66. public function testZonez1()
  67. {
  68. $zone = Zone::zonez1();
  69. $this->assertContains('upload-z1.qiniup.com', $zone->cdnUpHosts);
  70. }
  71. public function testZonez2()
  72. {
  73. $zone = Zone::zonez2();
  74. $this->assertContains('upload-z2.qiniup.com', $zone->cdnUpHosts);
  75. }
  76. public function testZoneNa0()
  77. {
  78. $zone = Zone::zoneNa0();
  79. $this->assertContains('upload-na0.qiniup.com', $zone->cdnUpHosts);
  80. }
  81. public function testZoneAs0()
  82. {
  83. $zone = Zone::zoneAs0();
  84. $this->assertContains('upload-as0.qiniup.com', $zone->cdnUpHosts);
  85. }
  86. public function testQvmZonez0()
  87. {
  88. $zone = Zone::qvmZonez0();
  89. $this->assertContains('free-qvm-z0-xs.qiniup.com', $zone->srcUpHosts);
  90. }
  91. public function testQvmZonez1()
  92. {
  93. $zone = Zone::qvmZonez1();
  94. $this->assertContains('free-qvm-z1-zz.qiniup.com', $zone->srcUpHosts);
  95. }
  96. }