FactoryTest.php 3.7 KB

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