Explorar el Código

[[ZF-3862]] Adding test case for serializing objects as base64

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17773 44c647ce-9c0f-0410-b52a-842ac1e357ba
lars hace 16 años
padre
commit
7fc2704fd5
Se han modificado 1 ficheros con 30 adiciones y 0 borrados
  1. 30 0
      tests/Zend/XmlRpc/ValueTest.php

+ 30 - 0
tests/Zend/XmlRpc/ValueTest.php

@@ -555,6 +555,22 @@ class Zend_XmlRpc_ValueTest extends PHPUnit_Framework_TestCase
         $this->assertContains($encoded, $xml);
     }
 
+    /**
+     * @group ZF-3862
+     */
+    public function testMarshalSerializedObjectAsBase64()
+    {
+        $o = new Zend_XmlRpc_SerializableTestClass();
+        $o->setProperty('foobar');
+        $serialized = serialize($o);
+        $val = Zend_XmlRpc_Value::getXmlRpcValue($serialized,
+                                    Zend_XmlRpc_Value::XMLRPC_TYPE_BASE64);
+
+        $this->assertXmlRpcType('base64', $val);
+        $o2 = unserialize($val->getValue());
+        $this->assertSame('foobar', $o2->getProperty());
+    }
+
     // Exceptions
 
     public function testFactoryThrowsWhenInvalidTypeSpecified()
@@ -581,6 +597,20 @@ class Zend_XmlRpc_ValueTest extends PHPUnit_Framework_TestCase
     }
 }
 
+class Zend_XmlRpc_SerializableTestClass
+{
+    protected $_property;
+    public function setProperty($property)
+    {
+        $this->_property = $property;
+    }
+
+    public function getProperty()
+    {
+        return $this->_property;
+    }
+}
+
 // Call Zend_XmlRpc_ValueTest::main() if this source file is executed directly.
 if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_ValueTest::main") {
     Zend_XmlRpc_ValueTest::main();