No Description

ConfigTest.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Qiniu\Tests {
  3. use Qiniu\Config;
  4. class ConfigTest extends \PHPUnit_Framework_TestCase
  5. {
  6. protected $accessKey;
  7. protected $bucketName;
  8. protected function setUp()
  9. {
  10. global $accessKey;
  11. $this->accessKey = $accessKey;
  12. global $bucketName;
  13. $this->bucketName = $bucketName;
  14. }
  15. public function testGetApiHost()
  16. {
  17. $conf = new Config();
  18. $hasException = false;
  19. $apiHost = '';
  20. try {
  21. $apiHost = $conf->getApiHost($this->accessKey, $this->bucketName);
  22. } catch (\Exception $e) {
  23. $hasException = true;
  24. }
  25. $this->assertFalse($hasException);
  26. $this->assertEquals('http://api.qiniu.com', $apiHost);
  27. }
  28. public function testGetApiHostErrored()
  29. {
  30. $conf = new Config();
  31. $hasException = false;
  32. try {
  33. $conf->getApiHost($this->accessKey, "fakebucket");
  34. } catch (\Exception $e) {
  35. $hasException = true;
  36. }
  37. $this->assertTrue($hasException);
  38. }
  39. }
  40. }