AbstractTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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$
  21. */
  22. require_once 'PHPUnit/Framework/TestCase.php';
  23. require_once 'Zend/Service/Amazon/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. */
  35. class AmamzonAbstract extends PHPUnit_Framework_TestCase
  36. {
  37. /**
  38. * Prepares the environment before running a test.
  39. */
  40. protected function setUp()
  41. {
  42. parent::setUp();
  43. }
  44. /**
  45. * Cleans up the environment after running a test.
  46. */
  47. protected function tearDown()
  48. {
  49. parent::tearDown();
  50. }
  51. public function testNoKeysThrowException()
  52. {
  53. try {
  54. $class = new TestAmamzonAbstract();
  55. $this->fail('Exception should be thrown when no keys are passed in.');
  56. } catch(Zend_Service_Amazon_Exception $zsae) {}
  57. }
  58. public function testConstructorWithKeysDoesNotThrowException()
  59. {
  60. try {
  61. $class = new TestAmamzonAbstract('TestAccessKey', 'TestSecretKey');
  62. } catch(Zend_Service_Amazon_Exception $zsae) {
  63. $this->fail('Exception should be thrown when no keys are passed in.');
  64. }
  65. }
  66. public function testSetStaticKeys()
  67. {
  68. TestAmamzonAbstract::setKeys('TestAccessKey', 'TestSecretKey');
  69. $class = new TestAmamzonAbstract();
  70. $this->assertEquals('TestAccessKey', $class->returnAccessKey());
  71. $this->assertEquals('TestSecretKey', $class->returnSecretKey());
  72. }
  73. public function testPassKeysIntoConstructor()
  74. {
  75. $class = new TestAmamzonAbstract('TestAccessKey', 'TestSecretKey');
  76. $this->assertEquals('TestAccessKey', $class->returnAccessKey());
  77. $this->assertEquals('TestSecretKey', $class->returnSecretKey());
  78. }
  79. public function testPassedInKeysOverrideStaticSetKeys()
  80. {
  81. TestAmamzonAbstract::setKeys('TestStaticAccessKey', 'TestStaticSecretKey');
  82. $class = new TestAmamzonAbstract('TestAccessKey', 'TestSecretKey');
  83. $this->assertEquals('TestAccessKey', $class->returnAccessKey());
  84. $this->assertEquals('TestSecretKey', $class->returnSecretKey());
  85. }
  86. }
  87. class TestAmamzonAbstract extends Zend_Service_Amazon_Abstract
  88. {
  89. public function returnAccessKey()
  90. {
  91. return $this->_accessKey;
  92. }
  93. public function returnSecretKey()
  94. {
  95. return $this->_secretKey;
  96. }
  97. }