Ver código fonte

[ZF-10665] Zend_Http_UserAgent

- fixed the return of the device to serialize.  

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23661 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon 15 anos atrás
pai
commit
ef95bdba19
2 arquivos alterados com 16 adições e 2 exclusões
  1. 3 2
      library/Zend/Http/UserAgent.php
  2. 13 0
      tests/Zend/Http/UserAgentTest.php

+ 3 - 2
library/Zend/Http/UserAgent.php

@@ -171,11 +171,12 @@ class Zend_Http_UserAgent implements Serializable
      */
      */
     public function serialize()
     public function serialize()
     {
     {
+        $device = $this->getDevice();
         $spec = array(
         $spec = array(
             'browser_type' => $this->_browserType,
             'browser_type' => $this->_browserType,
             'config'       => $this->_config,
             'config'       => $this->_config,
-            'device_class' => get_class($this->_device),
-            'device'       => $this->_device->serialize(),
+            'device_class' => get_class($device),
+            'device'       => $device->serialize(),
             'user_agent'   => $this->getServerValue('http_user_agent'),
             'user_agent'   => $this->getServerValue('http_user_agent'),
             'http_accept'  => $this->getServerValue('http_accept'),
             'http_accept'  => $this->getServerValue('http_accept'),
         );
         );

+ 13 - 0
tests/Zend/Http/UserAgentTest.php

@@ -565,4 +565,17 @@ class Zend_Http_UserAgentTest extends PHPUnit_Framework_TestCase
         $device    = $userAgent->getDevice();
         $device    = $userAgent->getDevice();
         $groups = $device->getAllGroups();
         $groups = $device->getAllGroups();
     }
     }
+
+    /**
+     * @group ZF-10665
+     */
+    public function testDontDieOnSerialization()
+    {
+        $config    = $this->config;
+        $userAgent = new Zend_Http_UserAgent($config);
+
+        // If this code doesn't throw a fatal error the test passed.
+        $userAgent->setUserAgent('userAgentTest');
+        $userAgent->serialize();
+    }
 }
 }