FactoryTest.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_Cloud
  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. */
  21. // Call Zend_Cloud_StorageService_FactoryTest::main() if this source file is executed directly.
  22. if (!defined("PHPUnit_MAIN_METHOD")) {
  23. define("PHPUnit_MAIN_METHOD", "Zend_Cloud_StorageService_FactoryTest::main");
  24. }
  25. /**
  26. * @see Zend_Config_Ini
  27. */
  28. require_once 'Zend/Config/Ini.php';
  29. /**
  30. * @see Zend_Cloud_QueueService_Factory
  31. */
  32. require_once 'Zend/Cloud/QueueService/Factory.php';
  33. require_once 'Zend/Cloud/QueueService/Adapter/ZendQueue.php';
  34. /**
  35. * Test class for Zend_Cloud_QueueService_Factory
  36. *
  37. * @category Zend
  38. * @package Zend_Cloud
  39. * @subpackage UnitTests
  40. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  41. * @license http://framework.zend.com/license/new-bsd New BSD License
  42. * @group Zend_Cloud
  43. */
  44. class Zend_Cloud_QueueService_FactoryTest extends PHPUnit_Framework_TestCase
  45. {
  46. /**
  47. * Runs the test methods of this class.
  48. *
  49. * @return void
  50. */
  51. public static function main()
  52. {
  53. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  54. $result = PHPUnit_TextUI_TestRunner::run($suite);
  55. }
  56. public function testGetQueueAdapterKey()
  57. {
  58. $this->assertTrue(is_string(Zend_Cloud_QueueService_Factory::QUEUE_ADAPTER_KEY));
  59. }
  60. public function testGetAdapterWithConfig()
  61. {
  62. // SQS adapter
  63. $sqsConfig = new Zend_Config_Ini(realpath(dirname(__FILE__) . '/_files/config/sqs.ini'));
  64. $sqsAdapter = Zend_Cloud_QueueService_Factory::getAdapter($sqsConfig);
  65. $this->assertEquals('Zend_Cloud_QueueService_Adapter_Sqs', get_class($sqsAdapter));
  66. // zend queue adapter
  67. $zqConfig = new Zend_Config_Ini(realpath(dirname(__FILE__) . '/_files/config/zendqueue.ini'));
  68. $zq = Zend_Cloud_QueueService_Factory::getAdapter($zqConfig);
  69. $this->assertEquals('Zend_Cloud_QueueService_Adapter_ZendQueue', get_class($zq));
  70. // Azure adapter
  71. $azureConfig = new Zend_Config_Ini(realpath(dirname(__FILE__) . '/_files/config/windowsazure.ini'));
  72. $azureAdapter = Zend_Cloud_QueueService_Factory::getAdapter($azureConfig);
  73. $this->assertEquals('Zend_Cloud_QueueService_Adapter_WindowsAzure', get_class($azureAdapter));
  74. }
  75. public function testGetAdapterWithArray()
  76. {
  77. // No need to overdo it; we'll test the array config with just one adapter.
  78. $zqConfig = array(Zend_Cloud_QueueService_Factory::QUEUE_ADAPTER_KEY =>
  79. 'Zend_Cloud_QueueService_Adapter_ZendQueue',
  80. Zend_Cloud_QueueService_Adapter_ZendQueue::ADAPTER => "Array");
  81. $zq = Zend_Cloud_QueueService_Factory::getAdapter($zqConfig);
  82. $this->assertEquals('Zend_Cloud_QueueService_Adapter_ZendQueue', get_class($zq));
  83. }
  84. }
  85. // Call Zend_Cloud_QueueService_FactoryTest::main() if this source file is executed directly.
  86. if (PHPUnit_MAIN_METHOD == "Zend_Cloud_QueueService_FactoryTest::main") {
  87. Zend_Cloud_QueueService_FactoryTest::main();
  88. }