Просмотр исходного кода

ZF-6130 The feature test allows for php to just retun it's class name if nothing is specified. Using _explicitType, setClassMap, getASClassName() should only be used now if you want to override the PHP class name for specifying the return type.


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15417 44c647ce-9c0f-0410-b52a-842ac1e357ba

wadearnold 16 лет назад
Родитель
Сommit
17d921a383
2 измененных файлов с 54 добавлено и 0 удалено
  1. 16 0
      tests/Zend/Amf/ContactVO.php
  2. 38 0
      tests/Zend/Amf/ResponseTest.php

+ 16 - 0
tests/Zend/Amf/ContactVO.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * Test Class for returning the name of the php class to flex.
+ * 
+ * @group ZF-6130
+ */
+class ContactVO
+{
+  public $id = 0;
+  public $firstname = "";
+  public $lastname = "";
+  public $email = "";
+  public $mobile = "";
+
+}
+?>

+ 38 - 0
tests/Zend/Amf/ResponseTest.php

@@ -11,6 +11,7 @@ require_once 'Zend/Amf/Value/MessageHeader.php';
 require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
 require_once 'Zend/Amf/Parse/TypeLoader.php';
 require_once 'Contact.php';
+require_once 'ContactVO.php';
 require_once 'Zend/Date.php';
 
 /**
@@ -736,6 +737,43 @@ class Zend_Amf_ResponseTest extends PHPUnit_Framework_TestCase
         // Check that the response matches the expected serialized value
         $this->assertEquals($mockResponse, $testResponse);
     }
+    
+   /**
+    * The feature test allows for php to just retun it's class name if nothing is specified. Using
+    * _explicitType, setClassMap, getASClassName() should only be used now if you want to override the 
+    * PHP class name for specifying the return type. 
+    * @group ZF-6130
+    */
+    public function testPhpObjectNameSerializedToAmf0ClassName()
+    {
+        $data = array();
+
+        $contact = new ContactVO();
+        $contact->id        = '15';
+        $contact->firstname = 'Joe';
+        $contact->lastname  = 'Smith';
+        $contact->email     = 'jsmith@adobe.com';
+        $contact->mobile    = '123-456-7890';
+        
+        array_push( $data, $contact );
+
+        $contact = new ContactVO();
+        $contact->id        = '23';
+        $contact->firstname = 'Adobe';
+        $contact->lastname  = 'Flex';
+        $contact->email     = 'was@here.com';
+        $contact->mobile    = '123-456-7890';
+        array_push( $data, $contact );
+        $newBody = new Zend_Amf_Value_MessageBody('/1/onResult',null,$data);
+        $this->_response->setObjectEncoding(0x00);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/typedObjectAmf0Response.bin');
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
 
 	/**
      * PHP float to Amf0 Number