2
0

BaseUserServiceTest.php 9.0 KB

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