FactoryTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_Queue
  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. * @version $Id$
  21. */
  22. /** Zend_Queue */
  23. require_once 'Zend/Queue.php';
  24. /** Zend_Queue_Exception */
  25. require_once 'Zend/Queue/Exception.php';
  26. /** Zend_Queue_Adapter_* */
  27. require_once 'Zend/Queue/Adapter/Array.php';
  28. require_once 'Zend/Queue/Adapter/Db.php';
  29. require_once 'Zend/Queue/Adapter/Memcacheq.php';
  30. require_once 'Zend/Queue/Adapter/ActivemqTest.php';
  31. /**
  32. * @category Zend
  33. * @package Zend_Queue
  34. * @subpackage UnitTests
  35. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. * @group Zend_Queue
  38. */
  39. class Zend_Queue_FactoryTest extends PHPUnit_Framework_TestCase
  40. {
  41. protected function setUp()
  42. {
  43. date_default_timezone_set('GMT');
  44. }
  45. public function testDb()
  46. {
  47. if ( TESTS_ZEND_QUEUE_DB === false ) {
  48. $this->markTestSkipped('Db setup required');
  49. }
  50. $options = json_decode(TESTS_ZEND_QUEUE_DB, true);
  51. $config = array('name' => 'queue1',
  52. 'driverOptions' => array('host' => $options['host'],
  53. 'username' => $options['username'],
  54. 'password' => $options['password'],
  55. 'dbname' => $options['dbname'],
  56. 'type' => $options['type'],
  57. 'port' => $options['port'])); // optional parameter
  58. $adapter = new Zend_Queue('Db', $config);
  59. $this->assertTrue($adapter instanceof Zend_Queue);
  60. }
  61. public function testMemcacheq()
  62. {
  63. if ( TESTS_ZEND_QUEUE_MEMCACHEQ_HOST === false ||
  64. TESTS_ZEND_QUEUE_MEMCACHEQ_PORT === false ) {
  65. $this->markTestSkipped('MemcacheQ setup required');
  66. }
  67. $config = array('name' => 'queue1',
  68. 'driverOptions' => array('host' => TESTS_ZEND_QUEUE_MEMCACHEQ_HOST,
  69. 'port' => TESTS_ZEND_QUEUE_MEMCACHEQ_PORT));
  70. $adapter = new Zend_Queue('Memcacheq', $config);
  71. $this->assertTrue($adapter instanceof Zend_Queue);
  72. }
  73. public function testActivemq()
  74. {
  75. if ( TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME === false ||
  76. TESTS_ZEND_QUEUE_ACTIVEMQ_HOST === false ||
  77. TESTS_ZEND_QUEUE_ACTIVEMQ_PORT === false ) {
  78. $this->markTestSkipped('ActiveMQ setup required');
  79. }
  80. $config = array('name' => 'queue1',
  81. 'driverOptions' => array('host' => TESTS_ZEND_QUEUE_ACTIVEMQ_HOST,
  82. 'port' => TESTS_ZEND_QUEUE_ACTIVEMQ_PORT,
  83. 'scheme' => TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME,
  84. 'username' => '',
  85. 'password' => ''));
  86. $adapter = new Zend_Queue('Activemq', $config);
  87. $this->assertTrue($adapter instanceof Zend_Queue);
  88. }
  89. public function testArray()
  90. {
  91. $config = array('name' => 'queue1',
  92. 'driverOptions' => array());
  93. $adapter = new Zend_Queue('Array', $config);
  94. $this->assertTrue($adapter instanceof Zend_Queue);
  95. }
  96. }