AbstractTest.php 2.6 KB

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