Parcourir la source

ZF-6130: Created reproduce case

- Simple endpoint with type-hinted item
- Note: Not getting the catchable fatal error mentioned, but definitely
  observing that createEmployee is not getting called

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24542 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew il y a 14 ans
Parent
commit
dd11b8e608

+ 41 - 0
tests/Zend/Amf/ServerTest.php

@@ -1135,6 +1135,47 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->assertNotSame($authAdapter->getAcl(), $this->_server->getAcl());
         $this->assertSame($acl, $this->_server->getAcl());
     }
+
+    /**
+     * @group ZF-6130
+     */
+    public function testServerShouldCastObjectArgumentsToAppropriateType()
+    {
+        $server = new Zend_Amf_Server();
+        $server->addDirectory(dirname(__FILE__) . '/_files/zf-6130/services');
+
+        // Create a mock message
+        $message = new Zend_Amf_Value_Messaging_RemotingMessage();
+        $message->operation = 'createEmployee';
+        $message->source = 'EmployeeService';
+        $message->body = json_encode(array(
+            'office'       => 322,
+            'departmentid' => 3,
+            'street'       => 32,
+            'zipcode'      => 32,
+            'state'        => 32,
+            'lastname'     => 4,
+            'firstname'    => 2,
+            'photofile'    => 322,
+            'city'         => 32,
+            'id'           => 1,
+            'title'        => 4,
+            'officephone'  => 233,
+            'email'        => 32,
+            'cellphone'    => 22,
+        ));
+        $body = new Zend_Amf_Value_MessageBody(null, "\1", $message);
+
+        $request = new Zend_Amf_Request();
+        $request->addAmfBody($body);
+        $request->setObjectEncoding(0x03);
+
+        $response = $server->handle($request);
+        $employee = EmployeeService::$employee;
+        $this->assertNotNull($employee);
+        $this->assertNotEquals(1, $employee->id);
+        $this->assertRegexp('/[a-z0-9]{3,}/', $employee->id);
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == "Zend_Amf_ServerTest::main") {

+ 25 - 0
tests/Zend/Amf/_files/zf-6130/Request_RawData.txt

@@ -0,0 +1,25 @@
+POST /FlexP-debug/gateway.php HTTP/1.1
+Host: 10.192.27.106
+User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1
+Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
+Accept-Language: en-gb,en;q=0.5
+Accept-Encoding: gzip, deflate
+Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
+Referer: http://10.192.27.106/FlexP-debug/FlexP.swf/[[DYNAMIC]]/4
+Content-type: application/x-amf
+Content-length: 422
+
+Flex Message (flex.messaging.messages.RemotingMessage)     operation = createEmployee    clientId = null    destination = EmployeeService    messageId = 2FB01F59-2951-0A30-8313-38E468189D0A    timestamp = 0    timeToLive = 0    body =     [      {office=322, departmentid=3, street=32, zipcode=32, state=32, lastname=4, firstname=2, photofile=322, city=32, id=1, title=4, officephone=233, email=32, cellphone=22}    ]    hdr(DSId) = nil
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 11 - 0
tests/Zend/Amf/_files/zf-6130/Response_withNoStrongType.txt

@@ -0,0 +1,11 @@
+HTTP/1.1 200 OK
+Date: Mon, 05 Sep 2011 09:39:51 GMT
+Server: Apache/2.2.17 (Win32) PHP/5.3.5 JRun/4.0
+X-Powered-By: PHP/5.3.5
+Cache-Control: no-cache, must-revalidate
+Expires: Thu, 19 Nov 1981 08:52:00 GMT
+Pragma: no-cache
+Content-Length: 288
+Content-Type: application/x-amf
+
+Flex Message (flex.messaging.messages.AcknowledgeMessage)     clientId = 763A913D-DF04-0D69-7B2C-000078E80DE4    correlationId = 7F65ED15-7784-1AAE-1047-38F547E639B9    destination = null    messageId = 0D7BEDCB-FD14-BA88-F382-000026AE9393    timestamp = 131521559200    timeToLive = 0    body = 13

+ 85 - 0
tests/Zend/Amf/_files/zf-6130/services/EmployeeService.php

@@ -0,0 +1,85 @@
+<?php
+class EmployeeService 
+{
+    public static $employee;
+
+    public function createEmployee(Employee $item) 
+    {
+        $item->id       = uniqid();
+        self::$employee = $item;
+        return $item->id;
+    }
+}
+
+class Employee 
+{
+    /**
+     * @var int
+     */
+    public $id;
+
+    /**
+     * @var string
+     */
+    public $firstname;
+
+    /**
+     * @var string
+     */
+    public $lastname;
+
+    /**
+     * @var string
+     */
+    public $title;
+
+    /**
+     * @var int
+     */
+    public $departmentid;
+
+    /**
+     * @var string
+     */
+    public $officephone;
+
+    /**
+     * @var string
+     */
+    public $cellphone;
+
+    /**
+     * @var string
+     */
+    public $email;
+
+    /**
+     * @var string
+     */
+    public $street;
+
+    /**
+     * @var string
+     */
+    public $city;
+
+    /**
+     * @var string
+     */
+    public $state;
+
+    /**
+     * @var string
+     */
+    public $zipcode;
+
+    /**
+     * @var string
+     */
+    public $office;
+
+    /**
+     * @var string
+     */
+    public $photofile;
+}