OfflineTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_Amazon
  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. require_once 'Zend/Service/Amazon/Sqs.php';
  23. require_once 'Zend/Service/Amazon/Sqs/Exception.php';
  24. require_once 'Zend/Http/Client/Adapter/Test.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Service_Amazon
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @group Zend_Service
  32. * @group Zend_Service_Amazon
  33. * @group Zend_Service_Amazon_Sqs
  34. */
  35. class Zend_Service_Amazon_Sqs_OfflineTest extends PHPUnit_Framework_TestCase
  36. {
  37. /**
  38. * Reference to Amazon service consumer object
  39. *
  40. * @var Zend_Service_Amazon_Sqs
  41. */
  42. protected $_amazon;
  43. /**
  44. * Test based HTTP client adapter
  45. *
  46. * @var Zend_Http_Client_Adapter_Test
  47. */
  48. protected $_httpClientAdapterTest;
  49. public function setUp()
  50. {
  51. //$this->markTestSkipped('No offline tests for Zend_Service_Amazon_Sqs');
  52. $this->_amazon= new Zend_Service_Amazon_Sqs('test','test');
  53. $this->_httpClientAdapterTest = new Zend_Http_Client_Adapter_Test();
  54. $this->_amazon->getHttpClient()
  55. ->setAdapter($this->_httpClientAdapterTest);
  56. }
  57. public function testSetRegion()
  58. {
  59. $this->_amazon->setEndpoint('eu-west-1');
  60. $endPoints= $this->_amazon->getEndpoints();
  61. $this->assertEquals($this->_amazon->getEndpoint(),$endPoints['eu-west-1']);
  62. }
  63. public function testSetNewRegion()
  64. {
  65. $this->_amazon->setEndpoint('foo');
  66. $this->assertEquals($this->_amazon->getEndpoint(),'sqs.foo.amazonaws.com');
  67. }
  68. public function testSetEmptyRegion()
  69. {
  70. $this->setExpectedException(
  71. 'Zend_Service_Amazon_Sqs_Exception',
  72. 'Empty region specified.'
  73. );
  74. $this->_amazon->setEndpoint('');
  75. }
  76. public function testGetRegions()
  77. {
  78. $endPoints= array('us-east-1' => 'sqs.us-east-1.amazonaws.com',
  79. 'us-west-1' => 'sqs.us-west-1.amazonaws.com',
  80. 'eu-west-1' => 'sqs.eu-west-1.amazonaws.com',
  81. 'ap-southeast-1' => 'sqs.ap-southeast-1.amazonaws.com',
  82. 'ap-northeast-1' => 'sqs.ap-northeast-1.amazonaws.com');
  83. $this->assertEquals($this->_amazon->getEndpoints(),$endPoints);
  84. }
  85. }