|
| 1 | +<?php |
| 2 | +namespace Qiniu\Tests; |
| 3 | + |
| 4 | +use Qiniu; |
| 5 | +use Qiniu\Zone; |
| 6 | + |
| 7 | +class ZoneTest extends \PHPUnit_Framework_TestCase |
| 8 | +{ |
| 9 | + protected $zone; |
| 10 | + protected $zoneHttps; |
| 11 | + protected $ak; |
| 12 | + |
| 13 | + protected $bucketName; |
| 14 | + protected $bucketNameBC; |
| 15 | + |
| 16 | + |
| 17 | + protected function setUp() |
| 18 | + { |
| 19 | + global $bucketName; |
| 20 | + $this->bucketName = $bucketName; |
| 21 | + |
| 22 | + global $bucketNameBC; |
| 23 | + $this->bucketNameBC = $bucketNameBC; |
| 24 | + |
| 25 | + global $accessKey; |
| 26 | + $this->ak = $accessKey; |
| 27 | + |
| 28 | + $this->zone = new Zone(); |
| 29 | + $this->zoneHttps = new Zone('https'); |
| 30 | + } |
| 31 | + |
| 32 | + public function testUpHosts() |
| 33 | + { |
| 34 | + |
| 35 | + list($upHosts, $err) = $this->zone->getUpHosts($this->ak, $this->bucketName); |
| 36 | + $this->assertNull($err); |
| 37 | + $this->assertEquals('http://up.qiniu.com', $upHosts[0]); |
| 38 | + $this->assertEquals('http://upload.qiniu.com', $upHosts[1]); |
| 39 | + |
| 40 | + list($upHosts, $err) = $this->zone->getUpHosts($this->ak, $this->bucketNameBC); |
| 41 | + $this->assertNull($err); |
| 42 | + $this->assertEquals('http://up-z1.qiniu.com', $upHosts[0]); |
| 43 | + $this->assertEquals('http://upload-z1.qiniu.com', $upHosts[1]); |
| 44 | + |
| 45 | + list($upHosts, $err) = $this->zoneHttps->getUpHosts($this->ak, $this->bucketName); |
| 46 | + $this->assertNull($err); |
| 47 | + $this->assertEquals('https://up.qbox.me', $upHosts[0]); |
| 48 | + |
| 49 | + list($upHosts, $err) = $this->zoneHttps->getUpHosts($this->ak, $this->bucketNameBC); |
| 50 | + $this->assertNull($err); |
| 51 | + $this->assertEquals('https://up-z1.qbox.me', $upHosts[0]); |
| 52 | + } |
| 53 | +} |
0 commit comments