AbstractTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: AbstractTest.php 17667 2009-08-18 21:40:09Z mikaelkael $
  21. */
  22. require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
  23. require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
  24. /**
  25. * @todo: Rename class to Zend_Service_Amazon_AbstractTest
  26. *
  27. * @category Zend
  28. * @package Zend_Service_Amazon
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Service
  33. * @group Zend_Service_Amazon
  34. * @group Zend_Service_Amazon_Ec2
  35. */
  36. class Zend_Service_Amazon_Ec2_AbstractTest extends PHPUnit_Framework_TestCase
  37. {
  38. /**
  39. * Prepares the environment before running a test.
  40. */
  41. protected function setUp()
  42. {
  43. parent::setUp();
  44. }
  45. /**
  46. * Cleans up the environment after running a test.
  47. */
  48. protected function tearDown()
  49. {
  50. parent::tearDown();
  51. }
  52. public function testNoKeysThrowException()
  53. {
  54. try {
  55. $class = new TestAmamzonAbstract();
  56. $this->fail('Exception should be thrown when no keys are passed in.');
  57. } catch(Zend_Service_Amazon_Exception $zsae) {}
  58. }
  59. public function testSetRegion()
  60. {
  61. TestAmamzonAbstract::setRegion('eu-west-1');
  62. $class = new TestAmamzonAbstract('TestAccessKey', 'TestSecretKey');
  63. $this->assertEquals('eu-west-1', $class->returnRegion());
  64. }
  65. public function testSetInvalidRegionThrowsException()
  66. {
  67. try {
  68. TestAmamzonAbstract::setRegion('eu-west-1a');
  69. $this->fail('Invalid Region Set with no Exception Thrown');
  70. } catch (Zend_Service_Amazon_Exception $zsae) {
  71. // do nothing
  72. }
  73. }
  74. }
  75. class TestAmamzonAbstract extends Zend_Service_Amazon_Ec2_Abstract
  76. {
  77. public function returnRegion()
  78. {
  79. return $this->_region;
  80. }
  81. }