2
0

FactoryTest.php 4.2 KB

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