Browse Source

Changes:

tests/Zend/Queue/Adapter/StompTest.php
* Cosmetic change.

tests/Zend/Queue/Custom/Queue.php
* Zend_Logger was removed in revision 16586, this completes the removal.

tests/Zend/Queue/FactoryTest.php
* The TestHelper.php is now included.
* Updated the code to use the TestConfiguration.php.(dist) values

library/Zend/Queue/Adapter/Apachemq.php
* Fixed "ACK" bug / submitted by Jason

library/Zend/Queue/Stomp/Client/Connection.php
* close() : Fixed these setCommand/write statements 
* re-commented out the fclose / socket=null; this needs to be solved: 
  http://framework.zend.com/issues/browse/ZF-7400
* Documentation fix / submitted by Jason

library/Zend/Queue/Stomp/Client/ConnectionInterface.php
* Documentation fix / submitted by Jason

Test status: Tests: 169, Assertions: 598, Skipped: 42.



git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17221 44c647ce-9c0f-0410-b52a-842ac1e357ba
danlo 16 years ago
parent
commit
5b64a05840

+ 1 - 1
library/Zend/Queue/Adapter/Apachemq.php

@@ -156,7 +156,7 @@ class Zend_Queue_Adapter_Apachemq extends Zend_Queue_Adapter_AdapterAbstract
     public function deleteMessage(Zend_Queue_Message $message)
     {
         $frame = $this->_client->createFrame();
-        $frame->setCommand('ack');
+        $frame->setCommand('ACK');
         $frame->setHeader('message-id', $message->handle);
 
         $this->_client->send($frame);

+ 12 - 5
library/Zend/Queue/Stomp/Client/Connection.php

@@ -110,15 +110,21 @@ class Zend_Queue_Stomp_Client_Connection
         // Gracefully disconnect
         if (!$destructor) {
             $frame = $this->createFrame();
-            $frame->command('DISCONNECT');
-            $this->write($frame->toFrame());
+            $frame->setCommand('DISCONNECT');
+            $this->write($frame);
         }
 
+        // @todo: Should be fixed.
+        // When the socket is "closed", it will trigger the below error when php exits
+        // Fatal error: Exception thrown without a stack frame in Unknown on line 0
+
+        // Danlo: I suspect this is because this has already been claimed by the interpeter
+        // thus trying to shutdown this resources, which is already shutdown is a problem.
         if (is_resource($this->_socket)) {
-            fclose($this->_socket);
+            // fclose($this->_socket);
         }
 
-        $this->_socket = null;
+        // $this->_socket = null;
     }
 
     /**
@@ -138,7 +144,8 @@ class Zend_Queue_Stomp_Client_Connection
 
     /**
      * Write a frame to the stomp server
-     * $response = $client->write($frame)->read();
+     *
+     * @example $response = $client->write($frame)->read();
      *
      * @param Zend_Queue_Stom_FrameInterface $frame
      * @return $this

+ 2 - 1
library/Zend/Queue/Stomp/Client/ConnectionInterface.php

@@ -56,7 +56,8 @@ interface Zend_Queue_Stomp_Client_ConnectionInterface
 
     /**
      * write a frame to the stomp server
-     * $response = $client->write($frame)->read();
+     *
+     * @example $response = $client->write($frame)->read();
      *
      * @param  Zend_Queue_Stomp_FrameInterface $frame
      * @return $this

+ 1 - 1
tests/Zend/Queue/Adapter/StompTest.php

@@ -78,7 +78,7 @@ class Zend_Queue_Adapter_StompTest extends Zend_Queue_Adapter_AdapterTest
     public function getTestConfig()
     {
         return array('driverOptions' => array('host' => '127.0.0.1',
-                                               'port' => '61613'));
+                                              'port' => '61613'));
     }
 
     /**

+ 0 - 2
tests/Zend/Queue/Custom/Queue.php

@@ -65,8 +65,6 @@ class Custom_Queue extends Zend_Queue
 
         $this->setMessageClass('Custom_Message');
         $this->setMessageSetClass('Custom_Messages');
-
-        $this->getLogger()->debug('Succcessfully created class: ' . get_class($this));
     }
 
     /**

+ 34 - 20
tests/Zend/Queue/FactoryTest.php

@@ -35,6 +35,8 @@ require_once 'Zend/Queue/Adapter/Db.php';
 require_once 'Zend/Queue/Adapter/Memcacheq.php';
 require_once 'Zend/Queue/Adapter/Apachemq.php';
 
+require_once dirname(__FILE__) . '/../../TestHelper.php';
+
 /**
  * @category   Zend
  * @package    Zend_Queue
@@ -52,15 +54,19 @@ class Zend_Queue_FactoryTest extends PHPUnit_Framework_TestCase
 
     public function testDb()
     {
-        $this->markTestSkipped('Db setup required');
+        if ( TESTS_ZEND_QUEUE_DB === false ) {
+            $this->markTestSkipped('Db setup required');
+        }
+
+        $options = json_decode(TESTS_ZEND_QUEUE_DB, true);
 
-        $config = array('name'           => 'queue1',
-                        'driverOptions' => array('host'     => 'db1.domain.tld',
-                                                 'username' => 'my_username',
-                                                 'password' => 'my_password',
-                                                 'dbname'   => 'messaging',
-                                                 'type'     => 'pdo_mysql',
-                                                 'port'     => 3306)); // optional parameter
+        $config = array('name'          => 'queue1',
+                        'driverOptions' => array('host'     => $options['host'],
+                                                 'username' => $options['username'],
+                                                 'password' => $options['password'],
+                                                 'dbname'   => $options['dbname'],
+                                                 'type'     => $options['type'],
+                                                 'port'     => $options['port'])); // optional parameter
 
         $adapter = new Zend_Queue('Db', $config);
 
@@ -69,11 +75,14 @@ class Zend_Queue_FactoryTest extends PHPUnit_Framework_TestCase
 
     public function testMemcacheq()
     {
-        $this->markTestSkipped('MemcacheQ setup required');
+        if ( TESTS_ZEND_QUEUE_MEMCACHEQ_HOST === false ||
+             TESTS_ZEND_QUEUE_MEMCACHEQ_PORT === false ) {
+            $this->markTestSkipped('MemcacheQ setup required');
+        }
 
-        $config = array('name'           => 'queue1',
-                        'driverOptions' => array('host' => 'memcacheq.domain.tld',
-                                                 'port' => 22201));
+        $config = array('name'          => 'queue1',
+                        'driverOptions' => array('host' => TESTS_ZEND_QUEUE_MEMCACHEQ_HOST,
+                                                 'port' => TESTS_ZEND_QUEUE_MEMCACHEQ_PORT));
 
         $adapter = new Zend_Queue('Memcacheq', $config);
 
@@ -82,22 +91,27 @@ class Zend_Queue_FactoryTest extends PHPUnit_Framework_TestCase
 
     public function testApachemq()
     {
-        $this->markTestSkipped('Stomp setup required');
+        if ( TESTS_ZEND_QUEUE_APACHEMQ_SCHEME === false ||
+             TESTS_ZEND_QUEUE_APACHEMQ_HOST === false ||
+             TESTS_ZEND_QUEUE_APACHEMQ_PORT === false ) {
+            $this->markTestSkipped('ApacheMQ setup required');
+        }
 
-        $config = array('name'           => 'queue1',
-                        'driverOptions' => array('host'     => 'msg.domain.tld',
-                                                 'port'     => 61613,
-                                                 'username' => 'username',
-                                                 'password' => 'password'));
+        $config = array('name'          => 'queue1',
+                        'driverOptions' => array('host'     => TESTS_ZEND_QUEUE_APACHEMQ_HOST,
+                                                 'port'     => TESTS_ZEND_QUEUE_APACHEMQ_PORT,
+                                                 'scheme'   => TESTS_ZEND_QUEUE_APACHEMQ_SCHEME,
+                                                 'username' => '',
+                                                 'password' => ''));
 
-        $adapter = new Zend_Queue('Stomp', $config);
+        $adapter = new Zend_Queue('Apachemq', $config);
 
         $this->assertTrue($adapter instanceof Zend_Queue);
     }
 
     public function testArray()
     {
-        $config = array('name' => 'queue1',
+        $config = array('name'          => 'queue1',
                         'driverOptions' => array());
 
         $adapter = new Zend_Queue('Array', $config);