123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- /**
- * Created by IntelliJ IDEA.
- * User: wf
- * Date: 2017/6/21
- * Time: AM8:46
- */
- namespace Qiniu\Tests;
- use Qiniu\Cdn\CdnManager;
- use Qiniu\Http\Client;
- class CdnManagerTest extends \PHPUnit_Framework_TestCase
- {
- protected $cdnManager;
- protected $encryptKey;
- protected $testStartDate;
- protected $testEndDate;
- protected $testGranularity;
- protected $testLogDate;
- protected $refreshUrl;
- protected $refreshDirs;
- protected $customDomain;
- protected $customDomain2;
- protected function setUp()
- {
- global $testAuth;
- $this->cdnManager = new CdnManager($testAuth);
- global $timestampAntiLeechEncryptKey;
- $this->encryptKey = $timestampAntiLeechEncryptKey;
- global $testStartDate;
- $this->testStartDate = $testStartDate;
- global $testEndDate;
- $this->testEndDate = $testEndDate;
- global $testGranularity;
- $this->testGranularity = $testGranularity;
- global $testLogDate;
- $this->testLogDate = $testLogDate;
- global $customDomain;
- $this->refreshUrl = $customDomain . '/sdktest.png';
- $this->refreshDirs = $customDomain;
- $this->customDomain = $customDomain;
- global $customDomain2;
- $this->customDomain2 = $customDomain2;
- }
- public function testRefreshUrls()
- {
- list($ret, $err) = $this->cdnManager->refreshUrls(array($this->refreshUrl));
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testRefreshDirs()
- {
- list($ret, $err) = $this->cdnManager->refreshDirs(array($this->refreshDirs));
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testRefreshUrlsAndDirs()
- {
- list($ret, $err) = $this->cdnManager->refreshUrlsAndDirs(array($this->refreshUrl), array($this->refreshDirs));
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testGetCdnRefreshList()
- {
- list($ret, $err) = $this->cdnManager->getCdnRefreshList(null, null, null, 'success');
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testPrefetchUrls()
- {
- list($ret, $err) = $this->cdnManager->prefetchUrls(array($this->refreshUrl));
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testGetCdnPrefetchList()
- {
- list($ret, $err) = $this->cdnManager->getCdnPrefetchList(null, null, 'success');
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testGetBandwidthData()
- {
- list($ret, $err) = $this->cdnManager->getBandwidthData(
- array($this->customDomain2),
- $this->testStartDate,
- $this->testEndDate,
- $this->testGranularity
- );
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testGetFluxData()
- {
- list($ret, $err) = $this->cdnManager->getFluxData(
- array($this->customDomain2),
- $this->testStartDate,
- $this->testEndDate,
- $this->testGranularity
- );
- $this->assertNull($err);
- $this->assertNotNull($ret);
- }
- public function testGetCdnLogList()
- {
- list($ret, $err) = $this->cdnManager->getCdnLogList(array('fake.qiniu.com'), $this->testLogDate);
- $this->assertNotNull($err);
- $this->assertNull($ret);
- }
- public function testCreateTimestampAntiLeechUrl()
- {
- $signUrl = $this->cdnManager->createTimestampAntiLeechUrl($this->refreshUrl, $this->encryptKey, 3600);
- $response = Client::get($signUrl);
- $this->assertNull($response->error);
- $this->assertEquals($response->statusCode, 200);
- $signUrl = $this->cdnManager->createTimestampAntiLeechUrl(
- $this->refreshUrl . '?qiniu',
- $this->encryptKey,
- 3600
- );
- $response = Client::get($signUrl);
- $this->assertNull($response->error);
- $this->assertEquals($response->statusCode, 200);
- }
- }
|