BaseUserServiceTest.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_DeveloperGarden
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. if (!defined('PHPUnit_MAIN_METHOD')) {
  23. define('PHPUnit_MAIN_METHOD', 'Zend_Service_DeveloperGarden_BaseUserServiceTest::main');
  24. }
  25. /**
  26. * @see Zend_Service_DeveloperGarden_BaseUserService
  27. */
  28. require_once 'Zend/Service/DeveloperGarden/BaseUserService.php';
  29. /**
  30. * Zend_Service_DeveloperGarden test case
  31. *
  32. * @category Zend
  33. * @package Zend_Service_DeveloperGarden
  34. * @subpackage UnitTests
  35. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. * @version $Id$
  38. */
  39. class Zend_Service_DeveloperGarden_BaseUserServiceTest extends PHPUnit_Framework_TestCase
  40. {
  41. /**
  42. * @todo add more tests for the ClientAbstract
  43. */
  44. /**
  45. * @var Zend_Service_DeveloperGarden_BaseUserService_Mock
  46. */
  47. protected $_service = null;
  48. protected $_limit = 10;
  49. public static function main()
  50. {
  51. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  52. PHPUnit_TextUI_TestRunner::run($suite);
  53. }
  54. public function setUp()
  55. {
  56. if (!defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED') ||
  57. TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED !== true) {
  58. $this->markTestSkipped('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED is not enabled');
  59. }
  60. if (!defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN')) {
  61. define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN', 'Unknown');
  62. }
  63. if (!defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD')) {
  64. define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD', 'Unknown');
  65. }
  66. $config = array(
  67. 'username' => TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN,
  68. 'password' => TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD,
  69. );
  70. $this->service = new Zend_Service_DeveloperGarden_BaseUserService_Mock($config);
  71. }
  72. public function testSmsQuotaSandbox()
  73. {
  74. $resp = $this->service->getSmsQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  75. $this->assertTrue($resp->isValid());
  76. $this->assertFalse($resp->hasError());
  77. }
  78. public function testSmsQuotaProduction()
  79. {
  80. $resp = $this->service->getSmsQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  81. $this->assertTrue($resp->isValid());
  82. $this->assertFalse($resp->hasError());
  83. }
  84. public function testVoiceCallQuotaSandbox()
  85. {
  86. $resp = $this->service->getVoiceCallQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  87. $this->assertTrue($resp->isValid());
  88. $this->assertFalse($resp->hasError());
  89. }
  90. public function testVoiceCallQuotaProduction()
  91. {
  92. $resp = $this->service->getVoiceCallQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  93. $this->assertTrue($resp->isValid());
  94. $this->assertFalse($resp->hasError());
  95. }
  96. public function testConfernceCallQuotaSandbox()
  97. {
  98. $resp = $this->service->getConfernceCallQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  99. $this->assertTrue($resp->isValid());
  100. $this->assertFalse($resp->hasError());
  101. }
  102. public function testConfernceCallQuotaProduction()
  103. {
  104. $resp = $this->service->getConfernceCallQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  105. $this->assertTrue($resp->isValid());
  106. $this->assertFalse($resp->hasError());
  107. }
  108. public function testLocalSearchQuotaSandbox()
  109. {
  110. $resp = $this->service->getLocalSearchQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  111. $this->assertTrue($resp->isValid());
  112. $this->assertFalse($resp->hasError());
  113. }
  114. public function testLocalSearchQuotaProduction()
  115. {
  116. $resp = $this->service->getLocalSearchQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  117. $this->assertTrue($resp->isValid());
  118. $this->assertFalse($resp->hasError());
  119. }
  120. public function testIPLocationQuotaSandbox()
  121. {
  122. $resp = $this->service->getIPLocationQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  123. $this->assertTrue($resp->isValid());
  124. $this->assertFalse($resp->hasError());
  125. }
  126. public function testIPLocationQuotaProduction()
  127. {
  128. $resp = $this->service->getIPLocationQuotaInformation(Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  129. $this->assertTrue($resp->isValid());
  130. $this->assertFalse($resp->hasError());
  131. }
  132. public function testChangeSmsQuotaPoolProduction()
  133. {
  134. $this->service->changeSmsQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  135. }
  136. public function testChangeSmsQuotaPoolSandbox()
  137. {
  138. $this->service->changeSmsQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  139. }
  140. public function testChangeVoiceCallQuotaPoolProduction()
  141. {
  142. $this->service->changeVoiceCallQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  143. }
  144. public function testChangeVoiceCallQuotaPoolSandbox()
  145. {
  146. $this->service->changeVoiceCallQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  147. }
  148. public function testChangeIPLocationQuotaPoolProduction()
  149. {
  150. $this->service->changeIPLocationQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  151. }
  152. public function testChangeIPLocationQuotaPoolSandbox()
  153. {
  154. $this->service->changeIPLocationQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  155. }
  156. public function testChangeConferenceCallQuotaPoolProduction()
  157. {
  158. $this->service->changeConferenceCallQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  159. }
  160. public function testChangeConferenceCallQuotaPoolSandbox()
  161. {
  162. $this->service->changeConferenceCallQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  163. }
  164. public function testChangeLocalSearchQuotaPoolProduction()
  165. {
  166. $this->service->changeLocalSearchQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_PRODUCTION);
  167. }
  168. public function testChangeLocalSearchQuotaPoolSandbox()
  169. {
  170. $this->service->changeLocalSearchQuotaPool($this->_limit, Zend_Service_DeveloperGarden_BaseUserService_Mock::ENV_SANDBOX);
  171. }
  172. public function testAccountBalance()
  173. {
  174. $result = $this->service->getAccountBalance();
  175. $this->assertEquals('0000', $result->getErrorCode());
  176. $this->assertTrue(is_array($result->Account));
  177. }
  178. public function testAccountBalanceLoop()
  179. {
  180. $result = $this->service->getAccountBalance();
  181. $this->assertEquals('0000', $result->getErrorCode());
  182. $this->assertTrue(is_array($result->Account));
  183. foreach ($result->Account as $k => $v) {
  184. $this->assertTrue(
  185. $v instanceof Zend_Service_DeveloperGarden_BaseUserService_AccountBalance
  186. );
  187. $this->assertTrue(is_string($v->getAccount()));
  188. $this->assertTrue(is_int($v->getCredits()));
  189. }
  190. }
  191. }
  192. class Zend_Service_DeveloperGarden_BaseUserService_Mock
  193. extends Zend_Service_DeveloperGarden_BaseUserService
  194. {
  195. /**
  196. * returns the correct module string
  197. *
  198. * @param string $module
  199. * @param integer $environment
  200. * @return string
  201. */
  202. public function getBuildModuleString($module, $environment)
  203. {
  204. return $this->_buildModuleString($module, $environment);
  205. }
  206. public function checkModuleId($moduleId)
  207. {
  208. return $this->_checkModuleId($moduleId);
  209. }
  210. public function buildModuleString($module, $environment)
  211. {
  212. return $this->_buildModuleString($module, $environment);
  213. }
  214. }
  215. if (PHPUnit_MAIN_METHOD == 'Zend_Service_DeveloperGarden_BaseUserServiceTest::main') {
  216. Zend_Service_DeveloperGarden_BaseUserServiceTest::main();
  217. }