AbstractTest.php 3.2 KB

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