Ver Fonte

[ZF-7497]Line endings in Zend/Amf

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17441 44c647ce-9c0f-0410-b52a-842ac1e357ba
yoshida@zend.co.jp há 16 anos atrás
pai
commit
e3debeaeed

+ 8 - 8
tests/Zend/Amf/Adobe/IntrospectorTest.php

@@ -18,7 +18,7 @@ class Zend_Amf_Adobe_IntrospectorTest extends PHPUnit_Framework_TestCase
         $suite  = new PHPUnit_Framework_TestSuite(__CLASS__);
         PHPUnit_TextUI_TestRunner::run($suite);
     }
-    
+
     public function setUp()
     {
         $this->introspector = new Zend_Amf_Adobe_Introspector();
@@ -108,7 +108,7 @@ class com_zend_framework_IntrospectorTest
 {
     /**
      * Constructor
-     * 
+     *
      * @return void
      */
     public function __construct()
@@ -117,8 +117,8 @@ class com_zend_framework_IntrospectorTest
 
     /**
      * Overloading: get properties
-     * 
-     * @param  string $name 
+     *
+     * @param  string $name
      * @return mixed
      */
     public function __get($name)
@@ -132,7 +132,7 @@ class com_zend_framework_IntrospectorTest
 
     /**
      * Foobar
-     * 
+     *
      * @param  string|int $arg
      * @return string|stdClass
      */
@@ -142,7 +142,7 @@ class com_zend_framework_IntrospectorTest
 
     /**
      * Barbaz
-     * 
+     *
      * @param  com_zend_framework_IntrospectorTestCustomType $arg
      * @return boolean
      */
@@ -151,8 +151,8 @@ class com_zend_framework_IntrospectorTest
     }
 
     /**
-     * Bazbat 
-     * 
+     * Bazbat
+     *
      * @return com_zend_framework_IntrospectorTestExplicitType
      */
     public function bazbat()

+ 1 - 1
tests/Zend/Amf/Adobe/_files/ZendAmfAdobeIntrospectorTest.php

@@ -3,7 +3,7 @@ class ZendAmfAdobeIntrospectorTest
 {
     /**
      * Foobar
-     * 
+     *
      * @param  string $arg
      * @return ZendAmfAdobeIntrospectorTestType
      */

+ 322 - 322
tests/Zend/Amf/AuthTest.php

@@ -1,322 +1,322 @@
-<?php
-// Call Zend_Amf_AuthTest::main() if this source file is executed directly.
-if (!defined("PHPUnit_MAIN_METHOD")) {
-    define("PHPUnit_MAIN_METHOD", "Zend_Amf_AuthTest::main");
-}
-
-require_once 'PHPUnit/Framework/TestCase.php';
-require_once dirname(__FILE__) . '/../../TestHelper.php';
-require_once 'Zend/Amf/Server.php';
-require_once 'Zend/Amf/Request.php';
-require_once 'Zend/Amf/Parse/TypeLoader.php';
-require_once 'Zend/Amf/Auth/Abstract.php';
-require_once 'Zend/Amf/Value/Messaging/RemotingMessage.php';
-require_once 'Zend/Session.php';
-require_once 'Zend/Auth/Result.php';
-require_once 'Zend/Acl.php';
-require_once 'Zend/Acl/Role.php';
-
-/**
- *  test case.
- */
-class Zend_Amf_AuthTest extends PHPUnit_Framework_TestCase
-{
-
-    /**
-     * Enter description here...
-     *
-     * @var Zend_Amf_Server
-     */
-    protected $_server;
-
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_AuthTest");
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    public function setUp()
-    {
-        $this->_server = new Zend_Amf_Server();
-        $this->_server->setProduction(false);
-        Zend_Amf_Parse_TypeLoader::resetMap();
-        $this->_acl = new Zend_Acl();
-    }
-	
-	protected function tearDown()
-	{
-        unset($this->_server);
-	}
-	protected function _addServiceCall($request, $class = 'Zend_Amf_Auth_testclass', $method = 'hello')
-	{
-		$data[] = "12345";
-        $this->_server->setClass($class);
-        $newBody = new Zend_Amf_Value_MessageBody("$class.$method","/1",$data);
-		$request->addAmfBody($newBody);
-	}
-	
-	protected function _addLogin($request, $username, $password)
-	{
-        $cmdBody = new Zend_Amf_Value_MessageBody("","/1","");
-        $loginCmd = new Zend_Amf_Value_Messaging_CommandMessage();
-        $cmdBody->setData($loginCmd);
-        $loginCmd->operation = Zend_Amf_Value_Messaging_CommandMessage::LOGIN_OPERATION;
-        $loginCmd->body = "$username:$password";
-        $request->addAmfBody($cmdBody);
-	}
-	
-	protected function _addLogout($request)
-	{
-        $cmdBody = new Zend_Amf_Value_MessageBody("","/1","");
-        $loginCmd = new Zend_Amf_Value_Messaging_CommandMessage();
-        $cmdBody->setData($loginCmd);
-        $loginCmd->operation = Zend_Amf_Value_Messaging_CommandMessage::LOGOUT_OPERATION;
-        $request->addAmfBody($cmdBody);
-	}
-	
-	protected function _callService($class = 'Zend_Amf_Auth_testclass', $method = 'hello')
-	{
-        $request = new Zend_Amf_Request();
-        $request->setObjectEncoding(0x03);
-        $this->_addServiceCall($request, $class, $method);
-        $this->_server->handle($request);
-        $response = $this->_server->getResponse();
-        $responseBody = $response->getAmfBodies();
-		return $responseBody[0]->getData();
-	}
-	
-	protected function _callServiceAuth($username, $password, $class = 'Zend_Amf_Auth_testclass', $method = 'hello')
-	{
-        $request = new Zend_Amf_Request();
-		$request->setObjectEncoding(0x03);
-		$this->_addLogin($request, $username, $password);
-        $this->_addServiceCall($request, $class, $method);
-        $this->_server->handle($request);
-		return $this->_server->getResponse()->getAmfBodies();
-	}
-	
-	public function testService()
-	{
-		$resp = $this->_callService();
-		$this->assertContains("hello", $resp);	
-	}
-
-	
-	public function testUnauthenticated()
-	{
-        Zend_Session::$_unitTestEnabled = true;
-		$this->_server->setAuth(new WrongPassword());
-		$this->_server->setAcl($this->_acl);
-		$data = $this->_callService();
-		$this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		$this->assertContains("not allowed", $data->faultString);
-	}
-
-	public function testAnonymousDenied()
-	{
-        Zend_Session::$_unitTestEnabled = true;
-		$this->_server->setAuth(new WrongPassword());
-		$this->_acl->addRole(new Zend_Acl_Role(Zend_Amf_Constants::GUEST_ROLE));
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callService();
-		$this->assertTrue($resp instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		$this->assertContains("not allowed", $resp->faultString);
-	}
-
-	public function testAnonymousOK()
-	{
-        Zend_Session::$_unitTestEnabled = true;
-		$this->_server->setAuth(new WrongPassword());
-		$this->_acl->addRole(new Zend_Acl_Role(Zend_Amf_Constants::GUEST_ROLE));
-		$this->_acl->allow(Zend_Amf_Constants::GUEST_ROLE, null, null);
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callService();
-		$this->assertContains("hello", $resp);	
-	}
-	
-	public function testNoUsername()
-	{
-		$this->_server->setAuth(new WrongPassword());
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("", "");
-		$data = $resp[0]->getData();
-		$this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		$this->assertContains("username not supplied", $data->faultString);
-	}
-
-	public function testWrongPassword()
-	{
-		$this->_server->setAuth(new WrongPassword());
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "");
-		$data = $resp[0]->getData();
-		$this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		$this->assertContains("Wrong Password", $data->faultString);
-	}
-
-	public function testRightPassword()
-	{
-        Zend_Session::$_unitTestEnabled = true;
-		$this->_server->setAuth(new RightPassword("testuser", "testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole"));
-		$this->_acl->allow("testrole", null, null);
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "");
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$this->assertContains("hello", $resp[1]->getData());	
-	}
-
-	// no ACL to allow access to this method
-	public function testNoAcl()
-	{
-		$this->_server->setAuth(new RightPassword("testuser", "testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole"));
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "");
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$data = $resp[1]->getData();
-		$this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		$this->assertContains("not allowed", $data->faultString);
-	}
-
-	// Class allows everybody to access, even though no ACL is defined
-	public function testNoClassAcl()
-	{
-		$this->_server->setAuth(new RightPassword("testuser", "testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole"));
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_NoAcl');
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$this->assertContains("hello", $resp[1]->getData());	
-	}
-
-	// Class-defined ACL
-	public function testClassAclAllowed()
-	{
-        Zend_Session::$_unitTestEnabled = true;
-		$this->_server->setAuth(new RightPassword("testuser", "testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole2"));
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_Acl');
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$this->assertContains("hello", $resp[1]->getData());	
-	}
-
-	// Class-defined ACL
-	public function testClassAclDenied()
-	{
-		$this->_server->setAuth(new RightPassword("testuser", "testrole2"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole2"));
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_Acl');
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$data = $resp[1]->getData();
-		$this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		$this->assertContains("not allowed", $data->faultString);
-	}
-
-	// Class-defined ACL
-	public function testClassAclAllowed2()
-	{
-        Zend_Session::$_unitTestEnabled = true;
-		$this->_server->setAuth(new RightPassword("testuser", "testrole2"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole2"));
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_Acl', 'hello2');
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$this->assertContains("hello", $resp[1]->getData());	
-	}
-
-	public function testLogout()
-	{
-        Zend_Session::$_unitTestEnabled = true;
-		$this->_server->setAuth(new RightPassword("testuser", "testrole"));
-		$this->_acl->addRole(new Zend_Acl_Role("testrole"));
-		$this->_acl->allow("testrole", null, null);
-		$this->_server->setAcl($this->_acl);
-		$resp = $this->_callServiceAuth("testuser", "");
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$this->assertContains("hello", $resp[1]->getData());	
-
-		// After logout same request should not be allowed
-        $this->setUp();
-        $this->_server->setAuth(new RightPassword("testuser", "testrole"));
-		$this->_server->setAcl($this->_acl);
-		$request = new Zend_Amf_Request();
-		$request->setObjectEncoding(0x03);
-		$this->_addLogout($request);
-		$this->_addServiceCall($request);
-		$this->_server->handle($request);
-		$resp = $this->_server->getResponse()->getAmfBodies();
-		
-		$this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
-		$data = $resp[1]->getData();	
-		$this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		$this->assertContains("not allowed", $data->faultString);
-	}
-}
-
-class WrongPassword extends Zend_Amf_Auth_Abstract
-{
-	public function authenticate() {
-		return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
-                null,
-                array('Wrong Password')
-                );
-	}    
-}
-
-class RightPassword extends Zend_Amf_Auth_Abstract
-{
-	public function __construct($name, $role) 
-	{
-		$this->_name = $name;
-		$this->_role = $role;	
-	}
-	public function authenticate() 
-	{
-		$id = new stdClass();
-        $id->role = $this->_role;
-        $id->name = $this->_name;
-        return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
-	}
-}
-
-class Zend_Amf_Auth_testclass {
-	function hello() {
-		return "hello!";
-	}
-}
-
-class Zend_Amf_Auth_testclass_Acl {
-	function hello() {
-		return "hello!";
-	}
-	
-	function hello2() {
-		return "hello2!";
-	}
-	
-	function initAcl(Zend_Acl $acl) {
-		$acl->allow("testrole", null, "hello");
-		$acl->allow("testrole2", null, "hello2");
-		return true;
-	}
-}
-
-class Zend_Amf_Auth_testclass_NoAcl {
-	function hello() {
-		return "hello!";
-	}
-	
-	function initAcl() {
-		return false;
-	}
-}
-
-if (PHPUnit_MAIN_METHOD == "Zend_Amf_AuthTest::main") {
-    Zend_Amf_AuthTest::main();
-}
+<?php
+// Call Zend_Amf_AuthTest::main() if this source file is executed directly.
+if (!defined("PHPUnit_MAIN_METHOD")) {
+    define("PHPUnit_MAIN_METHOD", "Zend_Amf_AuthTest::main");
+}
+
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once dirname(__FILE__) . '/../../TestHelper.php';
+require_once 'Zend/Amf/Server.php';
+require_once 'Zend/Amf/Request.php';
+require_once 'Zend/Amf/Parse/TypeLoader.php';
+require_once 'Zend/Amf/Auth/Abstract.php';
+require_once 'Zend/Amf/Value/Messaging/RemotingMessage.php';
+require_once 'Zend/Session.php';
+require_once 'Zend/Auth/Result.php';
+require_once 'Zend/Acl.php';
+require_once 'Zend/Acl/Role.php';
+
+/**
+ *  test case.
+ */
+class Zend_Amf_AuthTest extends PHPUnit_Framework_TestCase
+{
+
+    /**
+     * Enter description here...
+     *
+     * @var Zend_Amf_Server
+     */
+    protected $_server;
+
+    public static function main()
+    {
+        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_AuthTest");
+        PHPUnit_TextUI_TestRunner::run($suite);
+    }
+
+    public function setUp()
+    {
+        $this->_server = new Zend_Amf_Server();
+        $this->_server->setProduction(false);
+        Zend_Amf_Parse_TypeLoader::resetMap();
+        $this->_acl = new Zend_Acl();
+    }
+
+    protected function tearDown()
+    {
+        unset($this->_server);
+    }
+    protected function _addServiceCall($request, $class = 'Zend_Amf_Auth_testclass', $method = 'hello')
+    {
+        $data[] = "12345";
+        $this->_server->setClass($class);
+        $newBody = new Zend_Amf_Value_MessageBody("$class.$method","/1",$data);
+        $request->addAmfBody($newBody);
+    }
+
+    protected function _addLogin($request, $username, $password)
+    {
+        $cmdBody = new Zend_Amf_Value_MessageBody("","/1","");
+        $loginCmd = new Zend_Amf_Value_Messaging_CommandMessage();
+        $cmdBody->setData($loginCmd);
+        $loginCmd->operation = Zend_Amf_Value_Messaging_CommandMessage::LOGIN_OPERATION;
+        $loginCmd->body = "$username:$password";
+        $request->addAmfBody($cmdBody);
+    }
+
+    protected function _addLogout($request)
+    {
+        $cmdBody = new Zend_Amf_Value_MessageBody("","/1","");
+        $loginCmd = new Zend_Amf_Value_Messaging_CommandMessage();
+        $cmdBody->setData($loginCmd);
+        $loginCmd->operation = Zend_Amf_Value_Messaging_CommandMessage::LOGOUT_OPERATION;
+        $request->addAmfBody($cmdBody);
+    }
+
+    protected function _callService($class = 'Zend_Amf_Auth_testclass', $method = 'hello')
+    {
+        $request = new Zend_Amf_Request();
+        $request->setObjectEncoding(0x03);
+        $this->_addServiceCall($request, $class, $method);
+        $this->_server->handle($request);
+        $response = $this->_server->getResponse();
+        $responseBody = $response->getAmfBodies();
+        return $responseBody[0]->getData();
+    }
+
+    protected function _callServiceAuth($username, $password, $class = 'Zend_Amf_Auth_testclass', $method = 'hello')
+    {
+        $request = new Zend_Amf_Request();
+        $request->setObjectEncoding(0x03);
+        $this->_addLogin($request, $username, $password);
+        $this->_addServiceCall($request, $class, $method);
+        $this->_server->handle($request);
+        return $this->_server->getResponse()->getAmfBodies();
+    }
+
+    public function testService()
+    {
+        $resp = $this->_callService();
+        $this->assertContains("hello", $resp);
+    }
+
+
+    public function testUnauthenticated()
+    {
+        Zend_Session::$_unitTestEnabled = true;
+        $this->_server->setAuth(new WrongPassword());
+        $this->_server->setAcl($this->_acl);
+        $data = $this->_callService();
+        $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        $this->assertContains("not allowed", $data->faultString);
+    }
+
+    public function testAnonymousDenied()
+    {
+        Zend_Session::$_unitTestEnabled = true;
+        $this->_server->setAuth(new WrongPassword());
+        $this->_acl->addRole(new Zend_Acl_Role(Zend_Amf_Constants::GUEST_ROLE));
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callService();
+        $this->assertTrue($resp instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        $this->assertContains("not allowed", $resp->faultString);
+    }
+
+    public function testAnonymousOK()
+    {
+        Zend_Session::$_unitTestEnabled = true;
+        $this->_server->setAuth(new WrongPassword());
+        $this->_acl->addRole(new Zend_Acl_Role(Zend_Amf_Constants::GUEST_ROLE));
+        $this->_acl->allow(Zend_Amf_Constants::GUEST_ROLE, null, null);
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callService();
+        $this->assertContains("hello", $resp);
+    }
+
+    public function testNoUsername()
+    {
+        $this->_server->setAuth(new WrongPassword());
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("", "");
+        $data = $resp[0]->getData();
+        $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        $this->assertContains("username not supplied", $data->faultString);
+    }
+
+    public function testWrongPassword()
+    {
+        $this->_server->setAuth(new WrongPassword());
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "");
+        $data = $resp[0]->getData();
+        $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        $this->assertContains("Wrong Password", $data->faultString);
+    }
+
+    public function testRightPassword()
+    {
+        Zend_Session::$_unitTestEnabled = true;
+        $this->_server->setAuth(new RightPassword("testuser", "testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole"));
+        $this->_acl->allow("testrole", null, null);
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "");
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $this->assertContains("hello", $resp[1]->getData());
+    }
+
+    // no ACL to allow access to this method
+    public function testNoAcl()
+    {
+        $this->_server->setAuth(new RightPassword("testuser", "testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole"));
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "");
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $data = $resp[1]->getData();
+        $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        $this->assertContains("not allowed", $data->faultString);
+    }
+
+    // Class allows everybody to access, even though no ACL is defined
+    public function testNoClassAcl()
+    {
+        $this->_server->setAuth(new RightPassword("testuser", "testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole"));
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_NoAcl');
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $this->assertContains("hello", $resp[1]->getData());
+    }
+
+    // Class-defined ACL
+    public function testClassAclAllowed()
+    {
+        Zend_Session::$_unitTestEnabled = true;
+        $this->_server->setAuth(new RightPassword("testuser", "testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole2"));
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_Acl');
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $this->assertContains("hello", $resp[1]->getData());
+    }
+
+    // Class-defined ACL
+    public function testClassAclDenied()
+    {
+        $this->_server->setAuth(new RightPassword("testuser", "testrole2"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole2"));
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_Acl');
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $data = $resp[1]->getData();
+        $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        $this->assertContains("not allowed", $data->faultString);
+    }
+
+    // Class-defined ACL
+    public function testClassAclAllowed2()
+    {
+        Zend_Session::$_unitTestEnabled = true;
+        $this->_server->setAuth(new RightPassword("testuser", "testrole2"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole2"));
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "", 'Zend_Amf_Auth_testclass_Acl', 'hello2');
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $this->assertContains("hello", $resp[1]->getData());
+    }
+
+    public function testLogout()
+    {
+        Zend_Session::$_unitTestEnabled = true;
+        $this->_server->setAuth(new RightPassword("testuser", "testrole"));
+        $this->_acl->addRole(new Zend_Acl_Role("testrole"));
+        $this->_acl->allow("testrole", null, null);
+        $this->_server->setAcl($this->_acl);
+        $resp = $this->_callServiceAuth("testuser", "");
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $this->assertContains("hello", $resp[1]->getData());
+
+        // After logout same request should not be allowed
+        $this->setUp();
+        $this->_server->setAuth(new RightPassword("testuser", "testrole"));
+        $this->_server->setAcl($this->_acl);
+        $request = new Zend_Amf_Request();
+        $request->setObjectEncoding(0x03);
+        $this->_addLogout($request);
+        $this->_addServiceCall($request);
+        $this->_server->handle($request);
+        $resp = $this->_server->getResponse()->getAmfBodies();
+
+        $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
+        $data = $resp[1]->getData();
+        $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        $this->assertContains("not allowed", $data->faultString);
+    }
+}
+
+class WrongPassword extends Zend_Amf_Auth_Abstract
+{
+    public function authenticate() {
+        return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
+                null,
+                array('Wrong Password')
+                );
+    }
+}
+
+class RightPassword extends Zend_Amf_Auth_Abstract
+{
+    public function __construct($name, $role)
+    {
+        $this->_name = $name;
+        $this->_role = $role;
+    }
+    public function authenticate()
+    {
+        $id = new stdClass();
+        $id->role = $this->_role;
+        $id->name = $this->_name;
+        return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
+    }
+}
+
+class Zend_Amf_Auth_testclass {
+    function hello() {
+        return "hello!";
+    }
+}
+
+class Zend_Amf_Auth_testclass_Acl {
+    function hello() {
+        return "hello!";
+    }
+
+    function hello2() {
+        return "hello2!";
+    }
+
+    function initAcl(Zend_Acl $acl) {
+        $acl->allow("testrole", null, "hello");
+        $acl->allow("testrole2", null, "hello2");
+        return true;
+    }
+}
+
+class Zend_Amf_Auth_testclass_NoAcl {
+    function hello() {
+        return "hello!";
+    }
+
+    function initAcl() {
+        return false;
+    }
+}
+
+if (PHPUnit_MAIN_METHOD == "Zend_Amf_AuthTest::main") {
+    Zend_Amf_AuthTest::main();
+}

+ 15 - 15
tests/Zend/Amf/ContactVO.php

@@ -1,16 +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 = "";
-
-}
+<?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 = "";
+
+}
 ?>

+ 645 - 646
tests/Zend/Amf/RequestTest.php

@@ -1,646 +1,645 @@
-<?php
-if (!defined('PHPUnit_MAIN_METHOD')) {
-    define('PHPUnit_MAIN_METHOD', 'Zend_Amf_RequestTest::main');
-}
-
-require_once dirname(__FILE__) . '/../../TestHelper.php';
-require_once 'Zend/Amf/Request.php';
-require_once 'Zend/Amf/Parse/TypeLoader.php';
-require_once 'Zend/Locale.php';
-require_once 'Contact.php';
-
-
-/**
- * Test case for Zend_Amf_Request
- *
- * @package Zend_Amf
- * @subpackage UnitTests
- * @version $Id$
- */
-class Zend_Amf_RequestTest extends PHPUnit_Framework_TestCase
-{
-    /**
-     * Zend_Amf_Request object
-     * @var Zend_Amf_Request
-     */
-    protected $_request;
-
-    /**
-     * Runs the test methods of this class.
-     *
-     * @return void
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_RequestTest");
-        $result = PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
-     * Setup environment
-     */
-    public function setUp()
-    {
-        date_default_timezone_set("America/Chicago");
-        Zend_Locale::setDefault('en');
-        Zend_Amf_Parse_TypeLoader::resetMap();
-        $this->_request = new Zend_Amf_Request();
-    }
-
-    /**
-     * Teardown environment
-     */
-    public function tearDown()
-    {
-        unset($this->_request);
-    }
-
-    /**
-     * ActionScript undef to PHP null
-     *
-     */
-    public function testAmf3RemoteObjectUndefParameterDeserializedToNativePhpNull()
-    {
-        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/undefAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that no headers where recievedpbs
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnUndefined', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP null
-        $this->assertTrue(is_null($data[0]));
-    }
-
-    /**
-     * ActionScript String to PHP String
-     *
-     */
-    public function testAmf3RemoteObjectStringParameterDeserializedToNativePhpString()
-    {
-        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/stringAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnString', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP string
-        $this->assertTrue(is_string($data[0]));
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertEquals('abcdefghijklmpqrstuvwxyz', $data[0]);
-    }
-
-    /**
-     * ActionScript Array to Php Array
-     *
-     */
-    public function testAmf3RemoteObjectArrayParameterDeserializedToNativePhpArray()
-    {
-         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/arrayAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnArray', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP array
-        $this->assertTrue(is_array($data[0]));
-        // Make sure that the array was deserialized properly and check its value
-        $this->assertEquals('a', $data[0][0]);
-        $this->assertEquals('g', $data[0][6]);
-    }
-
-    /**
-     * ActionScript Numnber to PHP float
-     *
-     */
-    public function testAmf3NumberParameterDeserializedToNativePhpFloat()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/numberAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnNumber', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP float
-        $this->assertTrue(is_float($data[0]));
-        // Make sure that the float was deserialized properly and check its value
-        $this->assertEquals(31.57, $data[0]);
-    }
-
-    /**
-     * ActionScript Date to Php DateTime
-     *
-     */
-    public function testAmf3DateParameterDeserializedToNativeDateTime()
-    {
-        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/dateAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnDate', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that the array was deserialized properly and check its value
-        $this->assertEquals(1978, $data[0]->toString('Y'));
-
-    }
-
-    /**
-     * Try and read in the largest Amf Integer to PHP int
-     *
-     */
-    public function testAmf3LargeIntParameterDeserializedToNativePhpInt()
-    {
-         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/largeIntAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnInt', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP array
-        $this->assertTrue(is_int($data[0]));
-        // Make sure that the array was deserialized properly and check its value
-        $this->assertEquals(268435455, $data[0]);
-    }
-
-    /**
-     * Read boolean true and convert it to php boolean true
-     *
-     */
-    public function testAmf3BoolTrueParameterDeserializedToNativePhpBool()
-    {
-         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolTrueAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnBool', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP array
-        $this->assertTrue(is_bool($data[0]));
-        // Make sure that the Bool was deserialized properly and check its value
-        $this->assertEquals(true, $data[0]);
-    }
-
-    /**
-     * Convert boolean false to php boolean false.
-     *
-     */
-    public function testAmf3BoolFalseParameterDeserializedToNativePhpBool()
-    {
-         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolFalseAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnBool', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP array
-        $this->assertTrue(is_bool($data[0]));
-        // Make sure that the Bool was deserialized properly and check its value
-        $this->assertEquals(false, $data[0]);
-    }
-
-    public function testAmf3XmlParameterDeserializedToNativePhpSimpleXml()
-    {
-         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/xmlAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure the encoding type is properly set.
-        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $message = $bodies[0]->getData();
-        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
-        // Make sure that our endpoint is properly set.
-        $this->assertEquals('returnXml', $message->operation);
-        $this->assertEquals('RoundTrip', $message->source);
-        $data = $message->body;
-        // Make sure that we are dealing with a PHP simpleXml element
-        $this->assertTrue($data[0] instanceof SimpleXMLElement);
-        // Make sure that the xml was deserialized properly and check its value
-        $this->assertEquals('hello', (string) $data[0]->p);
-    }
-
-    public function testAmf3ByteArrayDeserializedToNativePhpString()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/byteArrayAmf3Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $requestBody = $this->_request->getAmfBodies();
-        $this->assertTrue($requestBody[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $requestBody[0]->getData();
-        // Make sure that we are dealing with a PHP string
-        $this->assertTrue(is_string($data[0]));
-        // Make sure that the string was deserialized properly and check its value
-        $byteArray = file_get_contents(dirname(__FILE__) .'/Request/bytearray.bin');
-        $this->assertEquals($byteArray, $data[0]);
-    }
-
-    /**
-     * Actionscript String to PHP String
-     *
-     */
-    public function testAmf0StringParameterDeserializedToNativePhpString()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/stringAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $requestBody = $this->_request->getAmfBodies();
-        $this->assertTrue($requestBody[0] instanceof Zend_Amf_Value_MessageBody);
-        $this->assertEquals('RoundTrip.returnString', $requestBody[0]->getTargetURI());
-        $data = $requestBody[0]->getData();
-        // Make sure that we are dealing with a PHP string
-        $this->assertTrue(is_string($data[0]));
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertEquals('abcdefghijklmpqrstuvwxyz', $data[0]);
-    }
-
-    /**
-     * ActionScript Object to PHP Object for Amf0
-     *
-     */
-    public function testAmf0ObjectParameterDeserializedToNativePhpObject()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/objectAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that we are dealing with a PHP string
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertEquals('foo', $data[0]->a);
-        $this->assertEquals('bar', $data[0]->b);
-    }
-
-    /**
-     * Test to make sure that a generic object as the first paramater does not crash
-     * @group ZF-5346
-     */
-    public function testAmf0ObjectFirstParameter()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/objectFirstParamRequest.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that we are dealing with a PHP string
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertEquals('foo', $data[0]->a);
-        $this->assertEquals('bar', $data[0]->b);
-        $this->assertEquals(1234, $data[1]);
-    }
-
-    /**
-     * ActionScript Mixed Array to PHP Object for Amf0
-     *
-     */
-    public function testAmf0MixedArrayParameterDeserializedToNativePhpObject()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/mixedArrayAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(array_key_exists(1, $data[0]));
-        $this->assertEquals('two', $data[0]->two);
-    }
-
-    /**
-     * ActionScript Numnber to PHP float
-     *
-     */
-    public function testAmf0NumberParameterDeserializedToNativePhpFloat()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/numberAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(is_float($data[0]));
-        $this->assertEquals(31.57, $data[0]);
-    }
-
-    /**
-     * ActionScript Date to PHP DateTime
-     *
-     */
-    public function testAmf0DateParameterDeserializedToNativePhpDateTime()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/dateAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertEquals(10, $data[0]->toString('M'));
-        $this->assertEquals(1978, $data[0]->toString('Y'));
-    }
-
-    /**
-     * ActionScript Integer to PHP int
-     *
-     */
-    public function testAmf0IntParameterDeserializedToNativePhpint()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/intAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertEquals(268435456, $data[0]);
-    }
-
-    /**
-     * Convert an Amf0 boolean true to php boolean
-     *
-     */
-    public function testAmf0BoolTrueParameterDeserializedToNativePhpBool()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolTrueAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(is_bool($data[0]));
-        $this->assertEquals(true, $data[0]);
-    }
-
-/**
-     * Convert an Amf0 boolean false to php boolean
-     *
-     */
-    public function testAmf0BoolFalseParameterDeserializedToNativePhpBool()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolFalseAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(is_bool($data[0]));
-        $this->assertEquals(false, $data[0]);
-    }
-
-    public function testAmf0NullDeserializedToNativePhpNull()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/nullAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(is_null($data[0]));
-    }
-
-   public function testAmf0UndefinedDeserializedToNativePhpNull()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/undefinedAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(is_null($data[0]));
-    }
-
-    public function testAmf0XmlParameterDeserializedToNativePhpSimpleXml()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/xmlAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that we are dealing with a PHP simpleXml element
-        $this->assertTrue($data[0] instanceof SimpleXMLElement);
-        // Make sure that the xml was deserialized properly and check its value
-        $this->assertEquals('hello', (string) $data[0]->p);
-    }
-
-    public function testAmf0ReferenceDeserialized()
-    {
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/referenceAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that we are dealing with a PHP a number
-        // Make sure that the xml was deserialized properly and check its value
-        $this->assertEquals('foo', (string) $data[0]->a);
-    }
-
-    public function testAmf0TypedObjecDeserializedToNativePHPObject()
-    {
-        Zend_Amf_Parse_TypeLoader::setMapping("ContactVO","Contact");
-        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/typedObjectAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
-        // Make sure that the message body was set after deserialization
-        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
-        $bodies = $this->_request->getAmfBodies();
-        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
-        $data = $bodies[0]->getData();
-        // Make sure that we are dealing with a PHP simpleXml element
-        $this->assertTrue($data[0] instanceof Contact);
-        // Make sure that the xml was deserialized properly and check its value
-        $this->assertEquals('arnold', (string) $data[0]->lastname);
-    }
-
-    public function testAmf0TypedObjecDeserializedToNativePHPObjectUnknownType()
-    {
-        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/bogusTypedObjectAmf0Request.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-
-        $requestBodies = $this->_request->getAmfBodies();
-        $messageBody   = reset($requestBodies);
-        $data          = $messageBody->getData();
-        $dataObject    = reset($data);
-
-        $this->assertEquals('stdClass', get_class($dataObject));
-    }
-
-    /**
-     * Test Amf0 credentials sent to the server
-     *
-     */
-    public function testAmf0CredentialsInHeader()
-    {
-
-    	$myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/credentialsheaderAmf0.bin');
-        // send the mock object request to be deserialized
-        $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
-        $this->assertEquals(1 , sizeof($this->_request->getAmfHeaders()));
-        $requestHeaders = $this->_request->getAmfHeaders();
-        $this->assertTrue($requestHeaders[0] instanceof Zend_Amf_Value_MessageHeader);
-        $this->assertEquals('Credentials', $requestHeaders[0]->name);
-        $this->assertFalse($requestHeaders[0]->mustRead);
-        $data = $requestHeaders[0]->data;
-        // Check the resulting header
-        $this->assertEquals('admin', $data->userid);
-        $this->assertEquals('pw123', $data->password);
-    }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Amf_RequestTest::main') {
-    Zend_Amf_RequestTest::main();
-}
+<?php
+if (!defined('PHPUnit_MAIN_METHOD')) {
+    define('PHPUnit_MAIN_METHOD', 'Zend_Amf_RequestTest::main');
+}
+
+require_once dirname(__FILE__) . '/../../TestHelper.php';
+require_once 'Zend/Amf/Request.php';
+require_once 'Zend/Amf/Parse/TypeLoader.php';
+require_once 'Zend/Locale.php';
+require_once 'Contact.php';
+
+
+/**
+ * Test case for Zend_Amf_Request
+ *
+ * @package Zend_Amf
+ * @subpackage UnitTests
+ * @version $Id$
+ */
+class Zend_Amf_RequestTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * Zend_Amf_Request object
+     * @var Zend_Amf_Request
+     */
+    protected $_request;
+
+    /**
+     * Runs the test methods of this class.
+     *
+     * @return void
+     */
+    public static function main()
+    {
+        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_RequestTest");
+        $result = PHPUnit_TextUI_TestRunner::run($suite);
+    }
+
+    /**
+     * Setup environment
+     */
+    public function setUp()
+    {
+        date_default_timezone_set("America/Chicago");
+        Zend_Locale::setDefault('en');
+        Zend_Amf_Parse_TypeLoader::resetMap();
+        $this->_request = new Zend_Amf_Request();
+    }
+
+    /**
+     * Teardown environment
+     */
+    public function tearDown()
+    {
+        unset($this->_request);
+    }
+
+    /**
+     * ActionScript undef to PHP null
+     *
+     */
+    public function testAmf3RemoteObjectUndefParameterDeserializedToNativePhpNull()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/undefAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that no headers where recievedpbs
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnUndefined', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP null
+        $this->assertTrue(is_null($data[0]));
+    }
+
+    /**
+     * ActionScript String to PHP String
+     *
+     */
+    public function testAmf3RemoteObjectStringParameterDeserializedToNativePhpString()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/stringAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnString', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP string
+        $this->assertTrue(is_string($data[0]));
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertEquals('abcdefghijklmpqrstuvwxyz', $data[0]);
+    }
+
+    /**
+     * ActionScript Array to Php Array
+     *
+     */
+    public function testAmf3RemoteObjectArrayParameterDeserializedToNativePhpArray()
+    {
+         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/arrayAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnArray', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP array
+        $this->assertTrue(is_array($data[0]));
+        // Make sure that the array was deserialized properly and check its value
+        $this->assertEquals('a', $data[0][0]);
+        $this->assertEquals('g', $data[0][6]);
+    }
+
+    /**
+     * ActionScript Numnber to PHP float
+     *
+     */
+    public function testAmf3NumberParameterDeserializedToNativePhpFloat()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/numberAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnNumber', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP float
+        $this->assertTrue(is_float($data[0]));
+        // Make sure that the float was deserialized properly and check its value
+        $this->assertEquals(31.57, $data[0]);
+    }
+
+    /**
+     * ActionScript Date to Php DateTime
+     *
+     */
+    public function testAmf3DateParameterDeserializedToNativeDateTime()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/dateAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnDate', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that the array was deserialized properly and check its value
+        $this->assertEquals(1978, $data[0]->toString('Y'));
+
+    }
+
+    /**
+     * Try and read in the largest Amf Integer to PHP int
+     *
+     */
+    public function testAmf3LargeIntParameterDeserializedToNativePhpInt()
+    {
+         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/largeIntAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnInt', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP array
+        $this->assertTrue(is_int($data[0]));
+        // Make sure that the array was deserialized properly and check its value
+        $this->assertEquals(268435455, $data[0]);
+    }
+
+    /**
+     * Read boolean true and convert it to php boolean true
+     *
+     */
+    public function testAmf3BoolTrueParameterDeserializedToNativePhpBool()
+    {
+         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolTrueAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnBool', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP array
+        $this->assertTrue(is_bool($data[0]));
+        // Make sure that the Bool was deserialized properly and check its value
+        $this->assertEquals(true, $data[0]);
+    }
+
+    /**
+     * Convert boolean false to php boolean false.
+     *
+     */
+    public function testAmf3BoolFalseParameterDeserializedToNativePhpBool()
+    {
+         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolFalseAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnBool', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP array
+        $this->assertTrue(is_bool($data[0]));
+        // Make sure that the Bool was deserialized properly and check its value
+        $this->assertEquals(false, $data[0]);
+    }
+
+    public function testAmf3XmlParameterDeserializedToNativePhpSimpleXml()
+    {
+         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/xmlAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure the encoding type is properly set.
+        $this->assertEquals(0x03, $this->_request->getObjectEncoding());
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $message = $bodies[0]->getData();
+        $this->assertTrue($message instanceof Zend_Amf_Value_Messaging_RemotingMessage);
+        // Make sure that our endpoint is properly set.
+        $this->assertEquals('returnXml', $message->operation);
+        $this->assertEquals('RoundTrip', $message->source);
+        $data = $message->body;
+        // Make sure that we are dealing with a PHP simpleXml element
+        $this->assertTrue($data[0] instanceof SimpleXMLElement);
+        // Make sure that the xml was deserialized properly and check its value
+        $this->assertEquals('hello', (string) $data[0]->p);
+    }
+
+    public function testAmf3ByteArrayDeserializedToNativePhpString()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/byteArrayAmf3Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $requestBody = $this->_request->getAmfBodies();
+        $this->assertTrue($requestBody[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $requestBody[0]->getData();
+        // Make sure that we are dealing with a PHP string
+        $this->assertTrue(is_string($data[0]));
+        // Make sure that the string was deserialized properly and check its value
+        $byteArray = file_get_contents(dirname(__FILE__) .'/Request/bytearray.bin');
+        $this->assertEquals($byteArray, $data[0]);
+    }
+
+    /**
+     * Actionscript String to PHP String
+     *
+     */
+    public function testAmf0StringParameterDeserializedToNativePhpString()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/stringAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $requestBody = $this->_request->getAmfBodies();
+        $this->assertTrue($requestBody[0] instanceof Zend_Amf_Value_MessageBody);
+        $this->assertEquals('RoundTrip.returnString', $requestBody[0]->getTargetURI());
+        $data = $requestBody[0]->getData();
+        // Make sure that we are dealing with a PHP string
+        $this->assertTrue(is_string($data[0]));
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertEquals('abcdefghijklmpqrstuvwxyz', $data[0]);
+    }
+
+    /**
+     * ActionScript Object to PHP Object for Amf0
+     *
+     */
+    public function testAmf0ObjectParameterDeserializedToNativePhpObject()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/objectAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that we are dealing with a PHP string
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertEquals('foo', $data[0]->a);
+        $this->assertEquals('bar', $data[0]->b);
+    }
+
+    /**
+     * Test to make sure that a generic object as the first paramater does not crash
+     * @group ZF-5346
+     */
+    public function testAmf0ObjectFirstParameter()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/objectFirstParamRequest.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that we are dealing with a PHP string
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertEquals('foo', $data[0]->a);
+        $this->assertEquals('bar', $data[0]->b);
+        $this->assertEquals(1234, $data[1]);
+    }
+
+    /**
+     * ActionScript Mixed Array to PHP Object for Amf0
+     *
+     */
+    public function testAmf0MixedArrayParameterDeserializedToNativePhpObject()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/mixedArrayAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertTrue(array_key_exists(1, $data[0]));
+        $this->assertEquals('two', $data[0]->two);
+    }
+
+    /**
+     * ActionScript Numnber to PHP float
+     *
+     */
+    public function testAmf0NumberParameterDeserializedToNativePhpFloat()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/numberAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertTrue(is_float($data[0]));
+        $this->assertEquals(31.57, $data[0]);
+    }
+
+    /**
+     * ActionScript Date to PHP DateTime
+     *
+     */
+    public function testAmf0DateParameterDeserializedToNativePhpDateTime()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/dateAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertEquals(10, $data[0]->toString('M'));
+        $this->assertEquals(1978, $data[0]->toString('Y'));
+    }
+
+    /**
+     * ActionScript Integer to PHP int
+     *
+     */
+    public function testAmf0IntParameterDeserializedToNativePhpint()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/intAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertEquals(268435456, $data[0]);
+    }
+
+    /**
+     * Convert an Amf0 boolean true to php boolean
+     *
+     */
+    public function testAmf0BoolTrueParameterDeserializedToNativePhpBool()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolTrueAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertTrue(is_bool($data[0]));
+        $this->assertEquals(true, $data[0]);
+    }
+
+/**
+     * Convert an Amf0 boolean false to php boolean
+     *
+     */
+    public function testAmf0BoolFalseParameterDeserializedToNativePhpBool()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/boolFalseAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertTrue(is_bool($data[0]));
+        $this->assertEquals(false, $data[0]);
+    }
+
+    public function testAmf0NullDeserializedToNativePhpNull()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/nullAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertTrue(is_null($data[0]));
+    }
+
+   public function testAmf0UndefinedDeserializedToNativePhpNull()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/undefinedAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that the string was deserialized properly and check its value
+        $this->assertTrue(is_null($data[0]));
+    }
+
+    public function testAmf0XmlParameterDeserializedToNativePhpSimpleXml()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/xmlAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that we are dealing with a PHP simpleXml element
+        $this->assertTrue($data[0] instanceof SimpleXMLElement);
+        // Make sure that the xml was deserialized properly and check its value
+        $this->assertEquals('hello', (string) $data[0]->p);
+    }
+
+    public function testAmf0ReferenceDeserialized()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/referenceAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that we are dealing with a PHP a number
+        // Make sure that the xml was deserialized properly and check its value
+        $this->assertEquals('foo', (string) $data[0]->a);
+    }
+
+    public function testAmf0TypedObjecDeserializedToNativePHPObject()
+    {
+        Zend_Amf_Parse_TypeLoader::setMapping("ContactVO","Contact");
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/typedObjectAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
+        // Make sure that the message body was set after deserialization
+        $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
+        $bodies = $this->_request->getAmfBodies();
+        $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
+        $data = $bodies[0]->getData();
+        // Make sure that we are dealing with a PHP simpleXml element
+        $this->assertTrue($data[0] instanceof Contact);
+        // Make sure that the xml was deserialized properly and check its value
+        $this->assertEquals('arnold', (string) $data[0]->lastname);
+    }
+
+    public function testAmf0TypedObjecDeserializedToNativePHPObjectUnknownType()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/bogusTypedObjectAmf0Request.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+
+        $requestBodies = $this->_request->getAmfBodies();
+        $messageBody   = reset($requestBodies);
+        $data          = $messageBody->getData();
+        $dataObject    = reset($data);
+
+        $this->assertEquals('stdClass', get_class($dataObject));
+    }
+
+    /**
+     * Test Amf0 credentials sent to the server
+     *
+     */
+    public function testAmf0CredentialsInHeader()
+    {
+        $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/credentialsheaderAmf0.bin');
+        // send the mock object request to be deserialized
+        $this->_request->initialize($myRequest);
+        // Make sure that no headers where recieved
+        $this->assertEquals(1 , sizeof($this->_request->getAmfHeaders()));
+        $requestHeaders = $this->_request->getAmfHeaders();
+        $this->assertTrue($requestHeaders[0] instanceof Zend_Amf_Value_MessageHeader);
+        $this->assertEquals('Credentials', $requestHeaders[0]->name);
+        $this->assertFalse($requestHeaders[0]->mustRead);
+        $data = $requestHeaders[0]->data;
+        // Check the resulting header
+        $this->assertEquals('admin', $data->userid);
+        $this->assertEquals('pw123', $data->password);
+    }
+}
+
+if (PHPUnit_MAIN_METHOD == 'Zend_Amf_RequestTest::main') {
+    Zend_Amf_RequestTest::main();
+}

+ 171 - 169
tests/Zend/Amf/ResourceTest.php

@@ -1,169 +1,171 @@
-<?php
-// Call Zend_Amf_AuthTest::main() if this source file is executed directly.
-if (!defined("PHPUnit_MAIN_METHOD")) {
-    define("PHPUnit_MAIN_METHOD", "Zend_Amf_ResourceTest::main");
-}
-
-require_once 'PHPUnit/Framework/TestCase.php';
-require_once dirname(__FILE__) . '/../../TestHelper.php';
-require_once 'Zend/Amf/Server.php';
-require_once 'Zend/Amf/Request.php';
-require_once 'Zend/Amf/Parse/TypeLoader.php';
-require_once 'Zend/Amf/Value/Messaging/RemotingMessage.php';
-
-/**
- *  test case.
- */
-class Zend_Amf_ResourceTest extends PHPUnit_Framework_TestCase
-{
-
-    /**
-     * Enter description here...
-     *
-     * @var Zend_Amf_Server
-     */
-    protected $_server;
-
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_ResourceTest");
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    public function setUp()
-    {
-        $this->_server = new Zend_Amf_Server();
-        $this->_server->setProduction(false);
-        Zend_Amf_Parse_TypeLoader::resetMap();
-    }
-	
-	protected function tearDown()
-	{
-        unset($this->_server);
-	}
-	
-	protected function _callService($method, $class = 'Zend_Amf_Resource_testclass')
-	{
-        $request = new Zend_Amf_Request();
-        $request->setObjectEncoding(0x03);
-        $this->_server->setClass($class);
-        $newBody = new Zend_Amf_Value_MessageBody("$class.$method","/1",array("test"));
-		$request->addAmfBody($newBody);
-        $this->_server->handle($request);
-        $response = $this->_server->getResponse();
-        return $response;
-	}
-	
-	public function testFile()
-	{
-		$resp = $this->_callService("returnFile");
-		$this->assertContains("test data", $resp->getResponse());
-	}
-	
-	/**
-	 * Defining new unknown resource type
-	 * 
-	 * @expectException Zend_Amf_Server_Exception
-	 *
-	 */
-	public function testCtxNoResource()
-	{
-		try {
-			$this->_callService("returnCtx");
-		} catch(Zend_Amf_Server_Exception $e) {
-			$this->assertContains("serialize resource type", $e->getMessage());
-			return;
-		}
-		$this->fail("Failed to throw exception on unknown resource");
-	}
-	
-	/**
-	 * Defining new unknown resource type via plugin loader and handling it
-	 *
-	 */ 
-	public function testCtxLoader()
-	{
-		Zend_Amf_Parse_TypeLoader::addResourceDirectory("Test_Resource", dirname(__FILE__)."/Resources");
-		$resp = $this->_callService("returnCtx");
-		$this->assertContains("Accept-language:", $resp->getResponse());
-		$this->assertContains("foo=bar", $resp->getResponse());
-	}
-	
-	/**
-	 * Defining new unknown resource type and handling it
-	 *
-	 */ 
-	public function testCtx()
-	{
-		Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Amf_TestResourceLoader("2"));
-		$resp = $this->_callService("returnCtx");
-		$this->assertContains("Accept-language:", $resp->getResponse());
-		$this->assertContains("foo=bar", $resp->getResponse());
-	}
-	
-	/**
-	 * Defining new unknown resource type, handler has no parse()
-	 *
-	 */ 
-	public function testCtxNoParse()
-	{
-		Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Amf_TestResourceLoader("3"));
-		try {
-			$resp = $this->_callService("returnCtx");
-		} catch(Zend_Amf_Server_Exception $e) {
-			$this->assertContains("Could not call parse()", $e->getMessage());
-			return;
-		}
-		$this->fail("Failed to throw exception on unknown resource");
-	}
-	
-}
-
-class Zend_Amf_Resource_testclass {
-	function returnFile() 
-	{
-		return fopen(dirname(__FILE__)."/_files/testdata", "r");
-	}
-	function returnCtx() 
-	{
-		$opts = array(
-  			'http'=>array(
-		    'method'=>"GET",
-    		'header'=>"Accept-language: en\r\n" .
-            	  "Cookie: foo=bar\r\n"
-  			)
-		);
-		$context = stream_context_create($opts);
-		return $context;
-	}
-}
-
-class StreamContext2
-{
-    public function parse($resource) {
-       		return stream_context_get_options($resource);
-	}
-}	
-class StreamContext3
-{
-    protected function parse($resource) {
-       		return stream_context_get_options($resource);
-	}
-}	
-class Zend_Amf_TestResourceLoader implements Zend_Loader_PluginLoader_Interface {
-	public $suffix;
-	public function __construct($suffix) {
-		$this->suffix = $suffix;
-	}
-    public function addPrefixPath($prefix, $path) {}
-    public function removePrefixPath($prefix, $path = null) {}
-    public function isLoaded($name) {}
-    public function getClassName($name) {}
-    public function load($name) {
-    	return $name.$this->suffix;
-    }
-}
-
-if (PHPUnit_MAIN_METHOD == "Zend_Amf_ResourceTest::main") {
-    Zend_Amf_ResourceTest::main();
-}
+<?php
+// Call Zend_Amf_AuthTest::main() if this source file is executed directly.
+if (!defined("PHPUnit_MAIN_METHOD")) {
+    define("PHPUnit_MAIN_METHOD", "Zend_Amf_ResourceTest::main");
+}
+
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once dirname(__FILE__) . '/../../TestHelper.php';
+require_once 'Zend/Amf/Server.php';
+require_once 'Zend/Amf/Request.php';
+require_once 'Zend/Amf/Parse/TypeLoader.php';
+require_once 'Zend/Amf/Value/Messaging/RemotingMessage.php';
+
+/**
+ *  test case.
+ */
+class Zend_Amf_ResourceTest extends PHPUnit_Framework_TestCase
+{
+
+    /**
+     * Enter description here...
+     *
+     * @var Zend_Amf_Server
+     */
+    protected $_server;
+
+    public static function main()
+    {
+        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_ResourceTest");
+        PHPUnit_TextUI_TestRunner::run($suite);
+    }
+
+    public function setUp()
+    {
+        $this->_server = new Zend_Amf_Server();
+        $this->_server->setProduction(false);
+        Zend_Amf_Parse_TypeLoader::resetMap();
+    }
+
+    protected function tearDown()
+    {
+        unset($this->_server);
+    }
+
+    protected function _callService($method, $class = 'Zend_Amf_Resource_testclass')
+    {
+        $request = new Zend_Amf_Request();
+        $request->setObjectEncoding(0x03);
+        $this->_server->setClass($class);
+        $newBody = new Zend_Amf_Value_MessageBody("$class.$method","/1",array("test"));
+        $request->addAmfBody($newBody);
+        $this->_server->handle($request);
+        $response = $this->_server->getResponse();
+        return $response;
+    }
+
+    public function testFile()
+    {
+        $resp = $this->_callService("returnFile");
+        $this->assertContains("test data", $resp->getResponse());
+    }
+
+    /**
+     * Defining new unknown resource type
+     *
+     * @expectException Zend_Amf_Server_Exception
+     *
+     */
+    public function testCtxNoResource()
+    {
+        try {
+            $this->_callService("returnCtx");
+        } catch(Zend_Amf_Server_Exception $e) {
+            $this->assertContains("serialize resource type", $e->getMessage());
+            return;
+        }
+        $this->fail("Failed to throw exception on unknown resource");
+    }
+
+    /**
+     * Defining new unknown resource type via plugin loader and handling it
+     *
+     */
+    public function testCtxLoader()
+    {
+        Zend_Amf_Parse_TypeLoader::addResourceDirectory("Test_Resource", dirname(__FILE__)."/Resources");
+        $resp = $this->_callService("returnCtx");
+        $this->assertContains("Accept-language:", $resp->getResponse());
+        $this->assertContains("foo=bar", $resp->getResponse());
+    }
+
+    /**
+     * Defining new unknown resource type and handling it
+     *
+     */
+    public function testCtx()
+    {
+        Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Amf_TestResourceLoader("2"));
+        $resp = $this->_callService("returnCtx");
+        $this->assertContains("Accept-language:", $resp->getResponse());
+        $this->assertContains("foo=bar", $resp->getResponse());
+    }
+
+    /**
+     * Defining new unknown resource type, handler has no parse()
+     *
+     */
+    public function testCtxNoParse()
+    {
+        Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Amf_TestResourceLoader("3"));
+        try {
+            $resp = $this->_callService("returnCtx");
+        } catch(Zend_Amf_Server_Exception $e) {
+            $this->assertContains("Could not call parse()", $e->getMessage());
+            return;
+        }
+        $this->fail("Failed to throw exception on unknown resource");
+    }
+
+}
+
+class Zend_Amf_Resource_testclass {
+    function returnFile()
+    {
+        return fopen(dirname(__FILE__)."/_files/testdata", "r");
+    }
+    function returnCtx()
+    {
+        $opts = array(
+            'http'=>array(
+            'method'=>"GET",
+            'header'=>"Accept-language: en\r\n" .
+                "Cookie: foo=bar\r\n"
+            )
+        );
+        $context = stream_context_create($opts);
+        return $context;
+    }
+}
+
+class StreamContext2
+{
+    public function parse($resource)
+    {
+        return stream_context_get_options($resource);
+    }
+}
+class StreamContext3
+{
+    protected function parse($resource)
+    {
+        return stream_context_get_options($resource);
+    }
+}
+class Zend_Amf_TestResourceLoader implements Zend_Loader_PluginLoader_Interface {
+    public $suffix;
+    public function __construct($suffix) {
+        $this->suffix = $suffix;
+    }
+    public function addPrefixPath($prefix, $path) {}
+    public function removePrefixPath($prefix, $path = null) {}
+    public function isLoaded($name) {}
+    public function getClassName($name) {}
+    public function load($name) {
+        return $name.$this->suffix;
+    }
+}
+
+if (PHPUnit_MAIN_METHOD == "Zend_Amf_ResourceTest::main") {
+    Zend_Amf_ResourceTest::main();
+}

+ 8 - 7
tests/Zend/Amf/Resources/StreamContext.php

@@ -1,7 +1,8 @@
-<?php
-class Zend_Amf_Parse_Resource_StreamContext
-	{
-	    public function parse($resource) {
-       		return stream_context_get_options($resource);
-	}
-}	
+<?php
+class Zend_Amf_Parse_Resource_StreamContext
+{
+    public function parse($resource)
+    {
+        return stream_context_get_options($resource);
+    }
+}

+ 1042 - 1042
tests/Zend/Amf/ResponseTest.php

@@ -1,1042 +1,1042 @@
-<?php
-if (!defined('PHPUnit_MAIN_METHOD')) {
-    define('PHPUnit_MAIN_METHOD', 'Zend_Amf_ResponseTest::main');
-}
-
-require_once dirname(__FILE__) . '/../../TestHelper.php';
-require_once 'Zend/Amf/Response.php';
-require_once 'Zend/Amf/Request.php';
-require_once 'Zend/Amf/Value/MessageBody.php';
-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';
-
-/**
- * Test case for Zend_Amf_Response
- *
- * @package Zend_Amf
- * @subpackage UnitTests
- * @version $Id$
- */
-class Zend_Amf_ResponseTest extends PHPUnit_Framework_TestCase
-{
-    // The message response status code.
-    public $responseURI = "/2/onResult";
-
-    /**
-     * Zend_Amf_Request object
-     * @var Zend_Amf_Request
-     */
-    protected $_response;
-
-    /**
-     * Runs the test methods of this class.
-     *
-     * @return void
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_ResponseTest");
-        $result = PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
-     * Setup environment
-     */
-    public function setUp()
-    {
-        date_default_timezone_set('America/Chicago');
-        Zend_Locale::setDefault('en_US');
-        Zend_Amf_Parse_TypeLoader::resetMap();
-        $this->_response = new Zend_Amf_Response();
-    }
-
-    /**
-     * Teardown environment
-     */
-    public function tearDown()
-    {
-        unset($this->_response);
-    }
-
-    /**
-     * PHP String to Amf String
-     *
-     */
-    public function testPhpStringSerializedToAmf3String()
-    {
-        // Create php object to serialize
-        $data = "zyxwvutsrqpmlkjihgfedcba";
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = 'C626EDB9-8CF4-C305-8915-096C8AA80E2E';
-        $acknowledgeMessage->clientId = '49D6F1AF-ADFB-3A48-5B2D-00000A5D0301';
-        $acknowledgeMessage->messageId = '5F58E888-58E8-12A9-7A85-00006D91CCB1';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124569861800';
-        $acknowledgeMessage->body = $data;
-
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI, null, $acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/stringAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-
-    /**
-     * PHP Arrat to Amf Array
-     *
-     */
-    public function testPhpArraySerializedToAmf3Array()
-    {
-        // Create php object to serialize
-        $data = array("g", "f", "e","d","c","b","a");
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = 'D3695635-7308-35A2-8451-09F7CAAB868A';
-        $acknowledgeMessage->clientId = '54A7E9A2-9C2A-9849-5A3D-000070318519';
-        $acknowledgeMessage->messageId = '2E68D735-A68E-D208-9ACC-00006FBCDE26';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124570774300';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI, null, $acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/arrayAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-	/**
-     * PHP float to Amf3 Number
-     *
-     */
-    public function testPhpFloatSerializedToAmf3Number()
-    {
-        $data    =  31.57;
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = '1D556448-6DF0-6D0B-79C7-09798CC54A93';
-        $acknowledgeMessage->clientId = '03EB43E5-3ADA-0F69-DA96-00007A54194D';
-        $acknowledgeMessage->messageId = '5E4C2B6B-ADAC-4C49-52B6-0000205BC451';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124569947000';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI, null, $acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/numberAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-	/**
-     * PHP DateTime to Amf Date
-     *
-     */
-    public function testPhpDateTimeSerializedToAmf3Date()
-    {
-        // Create php object to serialize
-        date_default_timezone_set('America/Chicago');
-        $dateSrc = '1978-10-23 4:20 America/Chicago';
-        $date = new DateTime($dateSrc, new DateTimeZone('America/Chicago'));
-        $data = $date;
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = '77D952FE-47FA-D789-83B6-097D43403C6C';
-        $acknowledgeMessage->clientId = '2D043296-C81C-7189-4325-000007D62DA1';
-        $acknowledgeMessage->messageId = '2A686BAF-7D69-11C8-9A0F-0000513C0958';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124569971300';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/dateAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    public function testZendDateTimeSerializedToAmf3Date()
-    {
-        // Create php object to serialize
-        $date = new Zend_Date('October 23, 1978', null, 'en_US');
-        $date->set('4:20:00',Zend_Date::TIMES);
-        $data = $date;
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = '77D952FE-47FA-D789-83B6-097D43403C6C';
-        $acknowledgeMessage->clientId = '2D043296-C81C-7189-4325-000007D62DA1';
-        $acknowledgeMessage->messageId = '2A686BAF-7D69-11C8-9A0F-0000513C0958';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124569971300';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/dateAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * Test the largest Integer that AS in can handle
-     *
-     */
-    public function testPhpLargeIntSerializedToAmf3Int()
-    {
-        // Create php object to serialize
-        $data = 268435455;
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = '1D191AC2-8628-2C9A-09B2-0981CBCCF2CC';
-        $acknowledgeMessage->clientId = '13D9DF0B-CCD0-1149-53D2-0000696908C2';
-        $acknowledgeMessage->messageId = '03387968-E9BA-E149-A230-00006366BE67';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124570001000';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/largeIntAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * Convert boolean true to php boolean true
-     *
-     */
-    public function testPhpBoolTrueSerializedToAmf3BoolTrue()
-    {
-        // Create php object to serialize
-        $data = true;
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = '45B8A430-A13A-FE86-D62F-098900BDF482';
-        $acknowledgeMessage->clientId = '4000C9FB-C97B-D609-DBAA-000048B69D81';
-        $acknowledgeMessage->messageId = '5F9AA1BF-D474-BB69-12C6-0000775127E8';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124570048300';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/boolTrueAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * Covert boolean false to PHP boolean false
-     *
-     */
-    public function testPhpBoolFalseSerializedToAmf3BoolFalse()
-    {
-        // Create php object to serialize
-        $data = false;
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = '9C5D0787-7301-432E-FD4F-098681A0EE30';
-        $acknowledgeMessage->clientId = '5AC2D840-E652-86A8-CB7A-00000418AAA4';
-        $acknowledgeMessage->messageId = '200337C4-0932-7D68-BB24-00005EBD5F95';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124570031900';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/boolFalseAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * test case for taking a PHP typed object and sending it back to flex as
-     * a typed object. uses explicit type
-     *
-     */
-    public function testPhpTypedObjectSerializedToAmf3TypedObjectExplicitType()
-    {
-        $data = array();
-
-        $contact = new Contact();
-        $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 Contact();
-        $contact->id = '23';
-        $contact->firstname = 'Adobe';
-        $contact->lastname = 'Flex';
-        $contact->email = 'was@here.com';
-        $contact->mobile = '123-456-7890';
-        array_push( $data, $contact );
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = 'AF307825-478F-C4CA-AC03-09C10CD02CCC';
-        $acknowledgeMessage->clientId = '702B4B03-89F5-34C8-1B4E-0000049466FA';
-        $acknowledgeMessage->messageId = '704B88DF-6D5E-A228-53E3-00001DA3041F';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124570415500';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/classMapAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * Test case for taking a PHP typed object and sending it back to flex as
-     * a typed object. uses getAsClassName
-     *
-     */
-    public function testPhpTypedObjectSerializedToAmf3TypedObjectGetAsClassName()
-    {
-        $data = array();
-
-        $contact = new Contact();
-        $contact->id = '15';
-        $contact->firstname = 'Joe';
-        $contact->lastname = 'Smith';
-        $contact->email = 'jsmith@adobe.com';
-        $contact->mobile = '123-456-7890';
-        unset($contact->_explicitType);
-        array_push( $data, $contact );
-
-        $contact = new Contact();
-        $contact->id = '23';
-        $contact->firstname = 'Adobe';
-        $contact->lastname = 'Flex';
-        $contact->email = 'was@here.com';
-        $contact->mobile = '123-456-7890';
-        unset($contact->_explicitType);
-        array_push( $data, $contact );
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = 'AF307825-478F-C4CA-AC03-09C10CD02CCC';
-        $acknowledgeMessage->clientId = '702B4B03-89F5-34C8-1B4E-0000049466FA';
-        $acknowledgeMessage->messageId = '704B88DF-6D5E-A228-53E3-00001DA3041F';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124570415500';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/classMapAmf3Response.bin');
-
-        // 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 testPhpObjectNameSerializedToAmf3ClassName()
-    {
-        $data = array();
-
-        $contact = new Contact();
-        $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 Contact();
-        $contact->id = '23';
-        $contact->firstname = 'Adobe';
-        $contact->lastname = 'Flex';
-        $contact->email = 'was@here.com';
-        $contact->mobile = '123-456-7890';
-        array_push( $data, $contact );
-
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = 'AF307825-478F-C4CA-AC03-09C10CD02CCC';
-        $acknowledgeMessage->clientId = '702B4B03-89F5-34C8-1B4E-0000049466FA';
-        $acknowledgeMessage->messageId = '704B88DF-6D5E-A228-53E3-00001DA3041F';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124570415500';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/classMapAmf3Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }    
-    
-    /**
-     * Returning a DOMDocument object to AMF is serialized into a XMString ready for E4X
-     * 
-     * @group ZF-4999
-     */
-    public function testPhpDomDocumentSerializedToAmf3XmlString()
-    {
-        $sXML = '<root><element><key>a</key><value>b</value></element></root>';
-		$data = new DOMDocument();
-		$data->preserveWhiteSpace = false;
-		$data->loadXML($sXML);
-        
-		// Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = 'B0B0E583-5A80-826B-C2D1-D67A63D2F5E1';
-        $acknowledgeMessage->clientId = '3D281DFB-FAC8-E368-3267-0000696DA53F';
-        $acknowledgeMessage->messageId = '436381AA-C8C1-9749-2B05-000067CEA2CD';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '122766401600';
-        $acknowledgeMessage->body = $data;
-
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/domdocumentAmf3Response.bin');
-        
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-    
-    /**
-     * Returning a SimpleXML object to AMF is serialized into a XMString ready for E4X
-     * 
-     * @group ZF-4999
-     */
-    public function testSimpleXmlSerializedToAmf3XmlString()
-    {
-        $sXML = '<root><element><key>a</key><value>b</value></element></root>';
-		$data = new DOMDocument();
-		$data->preserveWhiteSpace = false;
-		$data->loadXML($sXML);
-		$data = simplexml_import_dom($data);
-        
-		
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = 'B0B0E583-5A80-826B-C2D1-D67A63D2F5E1';
-        $acknowledgeMessage->clientId = '3D281DFB-FAC8-E368-3267-0000696DA53F';
-        $acknowledgeMessage->messageId = '436381AA-C8C1-9749-2B05-000067CEA2CD';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '122766401600';
-        $acknowledgeMessage->body = $data;
-        
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/domdocumentAmf3Response.bin');
-        
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-    
-    /**
-     * Check to make sure that cyclic references work inside of the AMF3 serializer
-     * @group ZF-6205
-     */
-    public function testReferenceObjectsToAmf3()
-    {
-        $data = new ReferenceTest();
-        $data = $data->getReference();
-        
-        // Create an acknowlege message for a response to a RemotingMessage
-        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
-        $acknowledgeMessage->correlationId = '839B091C-8DDF-F6DD-2FF1-EAA82AE39608';
-        $acknowledgeMessage->clientId = '21CC629C-58AF-2D68-A292-000006F8D883';
-        $acknowledgeMessage->messageId = '05E70A68-FF7F-D289-1A94-00004CCECA98';
-        $acknowledgeMessage->destination = null;
-        $acknowledgeMessage->timeToLive = 0;
-        $acknowledgeMessage->timestamp = '124518243200';
-        $acknowledgeMessage->body = $data;
-        
-        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
-
-        // serialize the data to an AMF output stream
-        $this->_response->setObjectEncoding(0x03);
-        $this->_response->addAmfBody($newBody);
-        $this->_response->finalize();
-        $testResponse = $this->_response->getResponse();
-
-        // Load the expected response.
-        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/referenceObjectAmf3Response.bin');
-        
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-        
-    }
-    
-    
-
-    /**
-     * PHP string to Amf0 string
-     *
-     */
-    public function testPhpStringSerializedToAmf0String()
-    {
-        $data = "zyxwvutsrqpmlkjihgfedcba";
-        $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/stringAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * PHP Array to Amf0 Array
-     *
-     */
-    public function testPhpArraySerializedToAmf0Array()
-    {
-        $data = array("g", "f", "e","d","c","b","a");
-        $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/arrayAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * Check to make sure that we can place arrays in arrays.
-     *
-     * @group	ZF-4712
-     */
-    public function testPhpNestedArraySerializedToAmf0Array()
-    {
-        $data = array("items"=>array("a","b"));
-        $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/nestedArrayAmf0Response.bin');
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-
-    }
-    
-    /**
-     * Allow sparse arrays to be retruned to Actionscript without loosing the keys. 
-     * 
-     * @group ZF-5094
-     */
-    public function testPhpSparseArraySerializedToAmf0Array()
-    {
-        $data = array(1 => 'foo', 5 => 'bar');
-        $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/sparseArrayAmf0Response.bin');
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-        
-    }
-    
-    /**
-     * Test to convert string keyed arrays are converted to objects so that we do not loose
-     * the key refrence in the associative array. 
-     * 
-     * @group ZF-5094
-     */
-    public function testPhpStringKeyArrayToAmf0Object()
-    {
-        $data = array('foo' => 5, 'bar' => 23);
-        $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/stringKeyArrayAmf0Response.bin');
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-        
-    }   
-
-	/**
-     * PHP Object to Amf0 Object
-     *
-     */
-    public function testPhpObjectSerializedToAmf0Object()
-    {
-        $data =  array('b'=>'bar',"a" =>'foo');
-        $data = (object) $data;
-        $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/objectAmf0Response.bin');
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    public function testPhpObjectSerializedToAmf0TypedObjectClassMap()
-    {
-        Zend_Amf_Parse_TypeLoader::setMapping("ContactVO","Contact");
-
-        $data = array();
-        $contact = new Contact();
-        $contact->id        = '15';
-        $contact->firstname = 'Joe';
-        $contact->lastname  = 'Smith';
-        $contact->email     = 'jsmith@adobe.com';
-        $contact->mobile    = '123-456-7890';
-        unset($contact->_explicitType);
-        array_push( $data, $contact );
-
-        $contact = new Contact();
-        $contact->id        = '23';
-        $contact->firstname = 'Adobe';
-        $contact->lastname  = 'Flex';
-        $contact->email     = 'was@here.com';
-        $contact->mobile    = '123-456-7890';
-        unset($contact->_explicitType);
-        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);
-    }
-
-
-    public function testPhpObjectSerializedToAmf0TypedObjectExplicitType()
-    {
-        $data = array();
-
-        $contact = new Contact();
-        $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 Contact();
-        $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);
-    }
-
-   public function testPhpObjectSerializedToAmf0TypedObjectGetAsClassName()
-    {
-        $data = array();
-
-        $contact = new Contact();
-        $contact->id        = '15';
-        $contact->firstname = 'Joe';
-        $contact->lastname  = 'Smith';
-        $contact->email     = 'jsmith@adobe.com';
-        $contact->mobile    = '123-456-7890';
-        unset($contact->_explicitType);
-        array_push( $data, $contact );
-
-        $contact = new Contact();
-        $contact->id        = '23';
-        $contact->firstname = 'Adobe';
-        $contact->lastname  = 'Flex';
-        $contact->email     = 'was@here.com';
-        $contact->mobile    = '123-456-7890';
-        unset($contact->_explicitType);
-        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);
-    }
-    
-   /**
-    * 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
-     *
-     */
-    public function testPhpFloatSerializedToAmf0Number()
-    {
-        $data =  31.57;
-        $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/numberAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-	/**
-     * PHP DateTime to Amf0 date
-     *
-     */
-    public function testPhpDateTimeSerializedToAmf0Date()
-    {
-        date_default_timezone_set('America/Chicago');
-        $dateSrc = '1978-10-23 4:20 America/Chicago';
-        $date = new DateTime($dateSrc, new DateTimeZone('America/Chicago'));
-        $data = $date;
-        $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/dateAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    public function testZendDateSerializedToAmf0Date()
-    {
-        $date = new Zend_Date('October 23, 1978', null, 'en_US');
-        $date->set('4:20:00',Zend_Date::TIMES);
-
-        $newBody = new Zend_Amf_Value_MessageBody('/1/onResult',null,$date);
-        $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/dateAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    /**
-     * PHP boolean true to Amf0 bool true.
-     *
-     */
-    public function testPhpBoolTrueSerializedToAmf0Bool()
-    {
-        $data = true;
-        $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/boolTrueAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-	/**
-     * PHP boolean true to Amf0 bool true.
-     *
-     */
-    public function testPhpBoolFalseSerializedToAmf0Bool()
-    {
-        $data = false;
-        $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/boolFalseAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    public function testPHPNullSerializedToAmf0Null()
-    {
-        $data = null;
-        $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/nullAmf0Response.bin');
-
-        // Check that the response matches the expected serialized value
-        $this->assertEquals($mockResponse, $testResponse);
-    }
-
-    public function testResponseShouldNotHaveMessageHeadersByDefault()
-    {
-        $headers = $this->_response->getAmfHeaders();
-        $this->assertEquals(0, count($headers));
-    }
-
-    public function testResponseShouldAggregateMessageHeaders()
-    {
-        $this->header1 = new Zend_Amf_Value_MessageHeader('foo', false, 'bar');
-        $this->header2 = new Zend_Amf_Value_MessageHeader('bar', true, 'baz');
-        $this->_response->addAmfHeader($this->header1)
-                        ->addAmfHeader($this->header2);
-        $headers = $this->_response->getAmfHeaders();
-        $this->assertEquals(2, count($headers));
-        $this->assertContains($this->header1, $headers);
-        $this->assertContains($this->header2, $headers);
-    }
-
-    public function testResponseHeadersShouldBeSerializedWhenWritingMessage()
-    {
-        $this->testResponseShouldAggregateMessageHeaders();
-        $this->_response->finalize();
-        $response = $this->_response->getResponse();
-
-        $request = new Zend_Amf_Request();
-        $request->initialize($response);
-        $headers = $request->getAmfHeaders();
-        $this->assertEquals(2, count($headers));
-    }
-
-    public function testToStringShouldProxyToGetResponse()
-    {
-        $this->testResponseShouldAggregateMessageHeaders();
-        $this->_response->finalize();
-        $response = $this->_response->getResponse();
-
-        $test = $this->_response->__toString();
-        $this->assertSame($response, $test);
-    }
-}
-
-/*
- * Used to test recursive cyclic references in the serializer. 
- *@group ZF-6205
- */
-class ReferenceTest {
-    public function getReference() { 
-        $o = new TestObject(); 
-        $o->recursive = new TestObject(); 
-        $o->recursive->recursive = $o; 
-        return $o; 
-    }
-}
-/**
- * @see ReferenceTest
- */
-class TestObject {
-    public $recursive;
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Amf_ResponseTest::main') {
-    Zend_Amf_ResponseTest::main();
-}
+<?php
+if (!defined('PHPUnit_MAIN_METHOD')) {
+    define('PHPUnit_MAIN_METHOD', 'Zend_Amf_ResponseTest::main');
+}
+
+require_once dirname(__FILE__) . '/../../TestHelper.php';
+require_once 'Zend/Amf/Response.php';
+require_once 'Zend/Amf/Request.php';
+require_once 'Zend/Amf/Value/MessageBody.php';
+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';
+
+/**
+ * Test case for Zend_Amf_Response
+ *
+ * @package Zend_Amf
+ * @subpackage UnitTests
+ * @version $Id$
+ */
+class Zend_Amf_ResponseTest extends PHPUnit_Framework_TestCase
+{
+    // The message response status code.
+    public $responseURI = "/2/onResult";
+
+    /**
+     * Zend_Amf_Request object
+     * @var Zend_Amf_Request
+     */
+    protected $_response;
+
+    /**
+     * Runs the test methods of this class.
+     *
+     * @return void
+     */
+    public static function main()
+    {
+        $suite  = new PHPUnit_Framework_TestSuite("Zend_Amf_ResponseTest");
+        $result = PHPUnit_TextUI_TestRunner::run($suite);
+    }
+
+    /**
+     * Setup environment
+     */
+    public function setUp()
+    {
+        date_default_timezone_set('America/Chicago');
+        Zend_Locale::setDefault('en_US');
+        Zend_Amf_Parse_TypeLoader::resetMap();
+        $this->_response = new Zend_Amf_Response();
+    }
+
+    /**
+     * Teardown environment
+     */
+    public function tearDown()
+    {
+        unset($this->_response);
+    }
+
+    /**
+     * PHP String to Amf String
+     *
+     */
+    public function testPhpStringSerializedToAmf3String()
+    {
+        // Create php object to serialize
+        $data = "zyxwvutsrqpmlkjihgfedcba";
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = 'C626EDB9-8CF4-C305-8915-096C8AA80E2E';
+        $acknowledgeMessage->clientId = '49D6F1AF-ADFB-3A48-5B2D-00000A5D0301';
+        $acknowledgeMessage->messageId = '5F58E888-58E8-12A9-7A85-00006D91CCB1';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124569861800';
+        $acknowledgeMessage->body = $data;
+
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI, null, $acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/stringAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+
+    /**
+     * PHP Arrat to Amf Array
+     *
+     */
+    public function testPhpArraySerializedToAmf3Array()
+    {
+        // Create php object to serialize
+        $data = array("g", "f", "e","d","c","b","a");
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = 'D3695635-7308-35A2-8451-09F7CAAB868A';
+        $acknowledgeMessage->clientId = '54A7E9A2-9C2A-9849-5A3D-000070318519';
+        $acknowledgeMessage->messageId = '2E68D735-A68E-D208-9ACC-00006FBCDE26';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124570774300';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI, null, $acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/arrayAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * PHP float to Amf3 Number
+     *
+     */
+    public function testPhpFloatSerializedToAmf3Number()
+    {
+        $data    =  31.57;
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = '1D556448-6DF0-6D0B-79C7-09798CC54A93';
+        $acknowledgeMessage->clientId = '03EB43E5-3ADA-0F69-DA96-00007A54194D';
+        $acknowledgeMessage->messageId = '5E4C2B6B-ADAC-4C49-52B6-0000205BC451';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124569947000';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI, null, $acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/numberAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * PHP DateTime to Amf Date
+     *
+     */
+    public function testPhpDateTimeSerializedToAmf3Date()
+    {
+        // Create php object to serialize
+        date_default_timezone_set('America/Chicago');
+        $dateSrc = '1978-10-23 4:20 America/Chicago';
+        $date = new DateTime($dateSrc, new DateTimeZone('America/Chicago'));
+        $data = $date;
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = '77D952FE-47FA-D789-83B6-097D43403C6C';
+        $acknowledgeMessage->clientId = '2D043296-C81C-7189-4325-000007D62DA1';
+        $acknowledgeMessage->messageId = '2A686BAF-7D69-11C8-9A0F-0000513C0958';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124569971300';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/dateAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    public function testZendDateTimeSerializedToAmf3Date()
+    {
+        // Create php object to serialize
+        $date = new Zend_Date('October 23, 1978', null, 'en_US');
+        $date->set('4:20:00',Zend_Date::TIMES);
+        $data = $date;
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = '77D952FE-47FA-D789-83B6-097D43403C6C';
+        $acknowledgeMessage->clientId = '2D043296-C81C-7189-4325-000007D62DA1';
+        $acknowledgeMessage->messageId = '2A686BAF-7D69-11C8-9A0F-0000513C0958';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124569971300';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/dateAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Test the largest Integer that AS in can handle
+     *
+     */
+    public function testPhpLargeIntSerializedToAmf3Int()
+    {
+        // Create php object to serialize
+        $data = 268435455;
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = '1D191AC2-8628-2C9A-09B2-0981CBCCF2CC';
+        $acknowledgeMessage->clientId = '13D9DF0B-CCD0-1149-53D2-0000696908C2';
+        $acknowledgeMessage->messageId = '03387968-E9BA-E149-A230-00006366BE67';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124570001000';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/largeIntAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Convert boolean true to php boolean true
+     *
+     */
+    public function testPhpBoolTrueSerializedToAmf3BoolTrue()
+    {
+        // Create php object to serialize
+        $data = true;
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = '45B8A430-A13A-FE86-D62F-098900BDF482';
+        $acknowledgeMessage->clientId = '4000C9FB-C97B-D609-DBAA-000048B69D81';
+        $acknowledgeMessage->messageId = '5F9AA1BF-D474-BB69-12C6-0000775127E8';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124570048300';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/boolTrueAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Covert boolean false to PHP boolean false
+     *
+     */
+    public function testPhpBoolFalseSerializedToAmf3BoolFalse()
+    {
+        // Create php object to serialize
+        $data = false;
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = '9C5D0787-7301-432E-FD4F-098681A0EE30';
+        $acknowledgeMessage->clientId = '5AC2D840-E652-86A8-CB7A-00000418AAA4';
+        $acknowledgeMessage->messageId = '200337C4-0932-7D68-BB24-00005EBD5F95';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124570031900';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/boolFalseAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * test case for taking a PHP typed object and sending it back to flex as
+     * a typed object. uses explicit type
+     *
+     */
+    public function testPhpTypedObjectSerializedToAmf3TypedObjectExplicitType()
+    {
+        $data = array();
+
+        $contact = new Contact();
+        $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 Contact();
+        $contact->id = '23';
+        $contact->firstname = 'Adobe';
+        $contact->lastname = 'Flex';
+        $contact->email = 'was@here.com';
+        $contact->mobile = '123-456-7890';
+        array_push( $data, $contact );
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = 'AF307825-478F-C4CA-AC03-09C10CD02CCC';
+        $acknowledgeMessage->clientId = '702B4B03-89F5-34C8-1B4E-0000049466FA';
+        $acknowledgeMessage->messageId = '704B88DF-6D5E-A228-53E3-00001DA3041F';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124570415500';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/classMapAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Test case for taking a PHP typed object and sending it back to flex as
+     * a typed object. uses getAsClassName
+     *
+     */
+    public function testPhpTypedObjectSerializedToAmf3TypedObjectGetAsClassName()
+    {
+        $data = array();
+
+        $contact = new Contact();
+        $contact->id = '15';
+        $contact->firstname = 'Joe';
+        $contact->lastname = 'Smith';
+        $contact->email = 'jsmith@adobe.com';
+        $contact->mobile = '123-456-7890';
+        unset($contact->_explicitType);
+        array_push( $data, $contact );
+
+        $contact = new Contact();
+        $contact->id = '23';
+        $contact->firstname = 'Adobe';
+        $contact->lastname = 'Flex';
+        $contact->email = 'was@here.com';
+        $contact->mobile = '123-456-7890';
+        unset($contact->_explicitType);
+        array_push( $data, $contact );
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = 'AF307825-478F-C4CA-AC03-09C10CD02CCC';
+        $acknowledgeMessage->clientId = '702B4B03-89F5-34C8-1B4E-0000049466FA';
+        $acknowledgeMessage->messageId = '704B88DF-6D5E-A228-53E3-00001DA3041F';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124570415500';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/classMapAmf3Response.bin');
+
+        // 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 testPhpObjectNameSerializedToAmf3ClassName()
+    {
+        $data = array();
+
+        $contact = new Contact();
+        $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 Contact();
+        $contact->id = '23';
+        $contact->firstname = 'Adobe';
+        $contact->lastname = 'Flex';
+        $contact->email = 'was@here.com';
+        $contact->mobile = '123-456-7890';
+        array_push( $data, $contact );
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = 'AF307825-478F-C4CA-AC03-09C10CD02CCC';
+        $acknowledgeMessage->clientId = '702B4B03-89F5-34C8-1B4E-0000049466FA';
+        $acknowledgeMessage->messageId = '704B88DF-6D5E-A228-53E3-00001DA3041F';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124570415500';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/classMapAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Returning a DOMDocument object to AMF is serialized into a XMString ready for E4X
+     *
+     * @group ZF-4999
+     */
+    public function testPhpDomDocumentSerializedToAmf3XmlString()
+    {
+        $sXML = '<root><element><key>a</key><value>b</value></element></root>';
+        $data = new DOMDocument();
+        $data->preserveWhiteSpace = false;
+        $data->loadXML($sXML);
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = 'B0B0E583-5A80-826B-C2D1-D67A63D2F5E1';
+        $acknowledgeMessage->clientId = '3D281DFB-FAC8-E368-3267-0000696DA53F';
+        $acknowledgeMessage->messageId = '436381AA-C8C1-9749-2B05-000067CEA2CD';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '122766401600';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/domdocumentAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Returning a SimpleXML object to AMF is serialized into a XMString ready for E4X
+     *
+     * @group ZF-4999
+     */
+    public function testSimpleXmlSerializedToAmf3XmlString()
+    {
+        $sXML = '<root><element><key>a</key><value>b</value></element></root>';
+        $data = new DOMDocument();
+        $data->preserveWhiteSpace = false;
+        $data->loadXML($sXML);
+        $data = simplexml_import_dom($data);
+
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = 'B0B0E583-5A80-826B-C2D1-D67A63D2F5E1';
+        $acknowledgeMessage->clientId = '3D281DFB-FAC8-E368-3267-0000696DA53F';
+        $acknowledgeMessage->messageId = '436381AA-C8C1-9749-2B05-000067CEA2CD';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '122766401600';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/domdocumentAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Check to make sure that cyclic references work inside of the AMF3 serializer
+     * @group ZF-6205
+     */
+    public function testReferenceObjectsToAmf3()
+    {
+        $data = new ReferenceTest();
+        $data = $data->getReference();
+
+        // Create an acknowlege message for a response to a RemotingMessage
+        $acknowledgeMessage = new Zend_Amf_Value_Messaging_AcknowledgeMessage(null);
+        $acknowledgeMessage->correlationId = '839B091C-8DDF-F6DD-2FF1-EAA82AE39608';
+        $acknowledgeMessage->clientId = '21CC629C-58AF-2D68-A292-000006F8D883';
+        $acknowledgeMessage->messageId = '05E70A68-FF7F-D289-1A94-00004CCECA98';
+        $acknowledgeMessage->destination = null;
+        $acknowledgeMessage->timeToLive = 0;
+        $acknowledgeMessage->timestamp = '124518243200';
+        $acknowledgeMessage->body = $data;
+
+        $newBody = new Zend_Amf_Value_MessageBody($this->responseURI,null,$acknowledgeMessage);
+
+        // serialize the data to an AMF output stream
+        $this->_response->setObjectEncoding(0x03);
+        $this->_response->addAmfBody($newBody);
+        $this->_response->finalize();
+        $testResponse = $this->_response->getResponse();
+
+        // Load the expected response.
+        $mockResponse = file_get_contents(dirname(__FILE__) .'/Response/mock/referenceObjectAmf3Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+
+    }
+
+
+
+    /**
+     * PHP string to Amf0 string
+     *
+     */
+    public function testPhpStringSerializedToAmf0String()
+    {
+        $data = "zyxwvutsrqpmlkjihgfedcba";
+        $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/stringAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * PHP Array to Amf0 Array
+     *
+     */
+    public function testPhpArraySerializedToAmf0Array()
+    {
+        $data = array("g", "f", "e","d","c","b","a");
+        $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/arrayAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * Check to make sure that we can place arrays in arrays.
+     *
+     * @group ZF-4712
+     */
+    public function testPhpNestedArraySerializedToAmf0Array()
+    {
+        $data = array("items"=>array("a","b"));
+        $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/nestedArrayAmf0Response.bin');
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+
+    }
+
+    /**
+     * Allow sparse arrays to be retruned to Actionscript without loosing the keys.
+     *
+     * @group ZF-5094
+     */
+    public function testPhpSparseArraySerializedToAmf0Array()
+    {
+        $data = array(1 => 'foo', 5 => 'bar');
+        $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/sparseArrayAmf0Response.bin');
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+
+    }
+
+    /**
+     * Test to convert string keyed arrays are converted to objects so that we do not loose
+     * the key refrence in the associative array.
+     *
+     * @group ZF-5094
+     */
+    public function testPhpStringKeyArrayToAmf0Object()
+    {
+        $data = array('foo' => 5, 'bar' => 23);
+        $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/stringKeyArrayAmf0Response.bin');
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+
+    }
+
+    /**
+     * PHP Object to Amf0 Object
+     *
+     */
+    public function testPhpObjectSerializedToAmf0Object()
+    {
+        $data =  array('b'=>'bar',"a" =>'foo');
+        $data = (object) $data;
+        $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/objectAmf0Response.bin');
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    public function testPhpObjectSerializedToAmf0TypedObjectClassMap()
+    {
+        Zend_Amf_Parse_TypeLoader::setMapping("ContactVO","Contact");
+
+        $data = array();
+        $contact = new Contact();
+        $contact->id        = '15';
+        $contact->firstname = 'Joe';
+        $contact->lastname  = 'Smith';
+        $contact->email     = 'jsmith@adobe.com';
+        $contact->mobile    = '123-456-7890';
+        unset($contact->_explicitType);
+        array_push( $data, $contact );
+
+        $contact = new Contact();
+        $contact->id        = '23';
+        $contact->firstname = 'Adobe';
+        $contact->lastname  = 'Flex';
+        $contact->email     = 'was@here.com';
+        $contact->mobile    = '123-456-7890';
+        unset($contact->_explicitType);
+        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);
+    }
+
+
+    public function testPhpObjectSerializedToAmf0TypedObjectExplicitType()
+    {
+        $data = array();
+
+        $contact = new Contact();
+        $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 Contact();
+        $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);
+    }
+
+   public function testPhpObjectSerializedToAmf0TypedObjectGetAsClassName()
+    {
+        $data = array();
+
+        $contact = new Contact();
+        $contact->id        = '15';
+        $contact->firstname = 'Joe';
+        $contact->lastname  = 'Smith';
+        $contact->email     = 'jsmith@adobe.com';
+        $contact->mobile    = '123-456-7890';
+        unset($contact->_explicitType);
+        array_push( $data, $contact );
+
+        $contact = new Contact();
+        $contact->id        = '23';
+        $contact->firstname = 'Adobe';
+        $contact->lastname  = 'Flex';
+        $contact->email     = 'was@here.com';
+        $contact->mobile    = '123-456-7890';
+        unset($contact->_explicitType);
+        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);
+    }
+
+   /**
+    * 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
+     *
+     */
+    public function testPhpFloatSerializedToAmf0Number()
+    {
+        $data =  31.57;
+        $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/numberAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * PHP DateTime to Amf0 date
+     *
+     */
+    public function testPhpDateTimeSerializedToAmf0Date()
+    {
+        date_default_timezone_set('America/Chicago');
+        $dateSrc = '1978-10-23 4:20 America/Chicago';
+        $date = new DateTime($dateSrc, new DateTimeZone('America/Chicago'));
+        $data = $date;
+        $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/dateAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    public function testZendDateSerializedToAmf0Date()
+    {
+        $date = new Zend_Date('October 23, 1978', null, 'en_US');
+        $date->set('4:20:00',Zend_Date::TIMES);
+
+        $newBody = new Zend_Amf_Value_MessageBody('/1/onResult',null,$date);
+        $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/dateAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * PHP boolean true to Amf0 bool true.
+     *
+     */
+    public function testPhpBoolTrueSerializedToAmf0Bool()
+    {
+        $data = true;
+        $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/boolTrueAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    /**
+     * PHP boolean true to Amf0 bool true.
+     *
+     */
+    public function testPhpBoolFalseSerializedToAmf0Bool()
+    {
+        $data = false;
+        $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/boolFalseAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    public function testPHPNullSerializedToAmf0Null()
+    {
+        $data = null;
+        $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/nullAmf0Response.bin');
+
+        // Check that the response matches the expected serialized value
+        $this->assertEquals($mockResponse, $testResponse);
+    }
+
+    public function testResponseShouldNotHaveMessageHeadersByDefault()
+    {
+        $headers = $this->_response->getAmfHeaders();
+        $this->assertEquals(0, count($headers));
+    }
+
+    public function testResponseShouldAggregateMessageHeaders()
+    {
+        $this->header1 = new Zend_Amf_Value_MessageHeader('foo', false, 'bar');
+        $this->header2 = new Zend_Amf_Value_MessageHeader('bar', true, 'baz');
+        $this->_response->addAmfHeader($this->header1)
+                        ->addAmfHeader($this->header2);
+        $headers = $this->_response->getAmfHeaders();
+        $this->assertEquals(2, count($headers));
+        $this->assertContains($this->header1, $headers);
+        $this->assertContains($this->header2, $headers);
+    }
+
+    public function testResponseHeadersShouldBeSerializedWhenWritingMessage()
+    {
+        $this->testResponseShouldAggregateMessageHeaders();
+        $this->_response->finalize();
+        $response = $this->_response->getResponse();
+
+        $request = new Zend_Amf_Request();
+        $request->initialize($response);
+        $headers = $request->getAmfHeaders();
+        $this->assertEquals(2, count($headers));
+    }
+
+    public function testToStringShouldProxyToGetResponse()
+    {
+        $this->testResponseShouldAggregateMessageHeaders();
+        $this->_response->finalize();
+        $response = $this->_response->getResponse();
+
+        $test = $this->_response->__toString();
+        $this->assertSame($response, $test);
+    }
+}
+
+/*
+ * Used to test recursive cyclic references in the serializer.
+ *@group ZF-6205
+ */
+class ReferenceTest {
+    public function getReference() {
+        $o = new TestObject();
+        $o->recursive = new TestObject();
+        $o->recursive->recursive = $o;
+        return $o;
+    }
+}
+/**
+ * @see ReferenceTest
+ */
+class TestObject {
+    public $recursive;
+}
+
+if (PHPUnit_MAIN_METHOD == 'Zend_Amf_ResponseTest::main') {
+    Zend_Amf_ResponseTest::main();
+}

+ 76 - 76
tests/Zend/Amf/ServerTest.php

@@ -213,7 +213,7 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->assertEquals("bar: foo", $responseBody[0]->getData(), var_export($responseBody, 1));
     }
 
-	/**
+    /**
      * Test to make sure that AMF3 basic requests are handled for loading
      * a class.
      * This type of call is sent from NetConnection rather than RemoteObject
@@ -297,7 +297,7 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         // Check the message body is the expected data to be returned
         $this->assertEquals("String: 12345", $acknowledgeMessage->body);
     }
- 
+
 
     /**
      * Test to make sure that you can have the same method name in two different classes.
@@ -792,10 +792,10 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
     {
         $this->assertNull($this->_server->loadFunctions(true));
     }
-    
+
    /**
      * @group ZF-5388
-     * Issue if only one parameter of type array is passed it is nested into another array. 
+     * Issue if only one parameter of type array is passed it is nested into another array.
      */
     public function testSingleArrayParamaterAMF3()
     {
@@ -824,12 +824,12 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         // check that we have a message beening returned
         $this->assertTrue($acknowledgeMessage instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
         // Check the message body is the expected data to be returned
-        $this->assertTrue($acknowledgeMessage->body);  
+        $this->assertTrue($acknowledgeMessage->body);
     }
-    
+
      /**
      * @group ZF-5388
-     * Issue if only one parameter of type array is passed it is nested into another array. 
+     * Issue if only one parameter of type array is passed it is nested into another array.
      */
     public function testSingleArrayParamaterAMF0()
     {
@@ -847,10 +847,10 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->assertTrue(array_key_exists(0, $responseBody), var_export($responseBody, 1));
         $this->assertTrue($responseBody[0]->getData(), var_export($responseBody, 1));
     }
-    
-	/**
+
+    /**
      * @group ZF-5388
-     * Issue if only one parameter of type array is passed it is nested into another array. 
+     * Issue if only one parameter of type array is passed it is nested into another array.
      */
     public function testMutiArrayParamaterAMF3()
     {
@@ -880,12 +880,12 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         // check that we have a message beening returned
         $this->assertTrue($acknowledgeMessage instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
         // Check the message body is the expected data to be returned
-        $this->assertEquals(4, count($acknowledgeMessage->body));  
+        $this->assertEquals(4, count($acknowledgeMessage->body));
     }
-    
+
      /**
      * @group ZF-5388
-     * Issue if multipol parameters are sent and one is of type array is passed. 
+     * Issue if multipol parameters are sent and one is of type array is passed.
      */
     public function testMutiArrayParamaterAMF0()
     {
@@ -904,7 +904,7 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->assertTrue(array_key_exists(0, $responseBody), var_export($responseBody, 1));
         $this->assertEquals(4, count($responseBody[0]->getData()), var_export($responseBody, 1));
     }
-    
+
     /**
      * @group ZF-5346
      */
@@ -936,12 +936,12 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         // check that we have a message beening returned
         $this->assertTrue($acknowledgeMessage instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
         // Check the message body is the expected data to be returned
-        $this->assertEquals(4, count($acknowledgeMessage->body));  
-        
+        $this->assertEquals(4, count($acknowledgeMessage->body));
+
     }
-    
-    
-    
+
+
+
     /**
      * Check that when using server->setSession you get an amf header that has an append to gateway sessionID
      * @group ZF-5381
@@ -949,10 +949,10 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
     public function testSessionAmf3()
     {
         Zend_Session::$_unitTestEnabled = true;
-        Zend_Session::start(); 
+        Zend_Session::start();
         $this->_server->setClass('Zend_Amf_testSession');
         $this->_server->setSession();
-        
+
         // create a mock remoting message
         $message = new Zend_Amf_Value_Messaging_RemotingMessage();
         $message->operation = 'getCount';
@@ -971,31 +971,31 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         // Now check if the return data was properly set.
         $acknowledgeMessage = $responseBody[0]->getData();
         // check that we have a message beening returned
-        $this->assertEquals(1, $acknowledgeMessage->body);  
-        // check that a header is being returned for the session id 
+        $this->assertEquals(1, $acknowledgeMessage->body);
+        // check that a header is being returned for the session id
         $headerBody = $response->getAmfHeaders();
         $this->assertEquals('AppendToGatewayUrl',$headerBody[0]->name);
-        
+
         // Do not stop session since it still can be used by other tests
         // Zend_Session::stop();
     }
-    
+
     public function testAddDirectory()
     {
-    	$this->_server->addDirectory(dirname(__FILE__)."/_files/services");
-    	$this->_server->addDirectory(dirname(__FILE__)."/_files/");
-    	$dirs = $this->_server->getDirectory();
-    	$this->assertContains(dirname(__FILE__)."/_files/services/", $dirs);
-    	$this->assertContains(dirname(__FILE__)."/_files/", $dirs);
+        $this->_server->addDirectory(dirname(__FILE__)."/_files/services");
+        $this->_server->addDirectory(dirname(__FILE__)."/_files/");
+        $dirs = $this->_server->getDirectory();
+        $this->assertContains(dirname(__FILE__)."/_files/services/", $dirs);
+        $this->assertContains(dirname(__FILE__)."/_files/", $dirs);
     }
-    
+
     public function testAddDirectoryService()
     {
-    	$this->_server->addDirectory(dirname(__FILE__)."/_files/services");
-    	// should take it from the path above, not include path
+        $this->_server->addDirectory(dirname(__FILE__)."/_files/services");
+        // should take it from the path above, not include path
         $origPath = get_include_path();
-    	set_include_path($origPath.PATH_SEPARATOR.dirname(__FILE__));
-    	// create a mock remoting message
+        set_include_path($origPath.PATH_SEPARATOR.dirname(__FILE__));
+        // create a mock remoting message
         $message = new Zend_Amf_Value_Messaging_RemotingMessage();
         $message->operation = 'getMenu';
         $message->source = 'ServiceC';
@@ -1013,11 +1013,11 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($response[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
         $this->assertEquals("Service: MenuC", $response[0]->getData()->body);
     }
-    
+
     public function testAddDirectoryService2()
     {
-    	$this->_server->addDirectory(dirname(__FILE__)."/_files/services");
-    	// create a mock remoting message
+        $this->_server->addDirectory(dirname(__FILE__)."/_files/services");
+        // create a mock remoting message
         $message = new Zend_Amf_Value_Messaging_RemotingMessage();
         $message->operation = 'getMenu';
         $message->source = 'My.ServiceA';
@@ -1034,14 +1034,14 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($response[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage);
         $this->assertEquals("Service: myMenuA", $response[0]->getData()->body);
     }
-    
+
     /*
      * See ZF-6625
      */
     public function testAddDirectoryServiceNotFound()
     {
-    	$this->_server->addDirectory(dirname(__FILE__)."/_files/services");
-    	// create a mock remoting message
+        $this->_server->addDirectory(dirname(__FILE__)."/_files/services");
+        // create a mock remoting message
         $message = new Zend_Amf_Value_Messaging_RemotingMessage();
         $message->operation = 'encode';
         $message->source = 'Zend_Json';
@@ -1056,18 +1056,18 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->_server->handle($request);
         $response = $this->_server->getResponse()->getAMFBodies();
         $this->assertTrue($response[0]->getData() instanceof Zend_Amf_Value_Messaging_ErrorMessage);
-		// test the same while ensuring Zend_Json is loaded
-		require_once 'Zend/Json.php';
-		$this->_server->handle($request);
-		$response = $this->_server->getResponse()->getAMFBodies();
-		$this->assertTrue($response[0]->getData() instanceof Zend_Amf_Value_Messaging_ErrorMessage);
+        // test the same while ensuring Zend_Json is loaded
+        require_once 'Zend/Json.php';
+        $this->_server->handle($request);
+        $response = $this->_server->getResponse()->getAMFBodies();
+        $this->assertTrue($response[0]->getData() instanceof Zend_Amf_Value_Messaging_ErrorMessage);
     }
 
     /* See ZF-7102 */
     public function testCtorExcection()
     {
-		$this->_server->setClass('Zend_Amf_testException');
-		$this->_server->setProduction(false);
+        $this->_server->setClass('Zend_Amf_testException');
+        $this->_server->setProduction(false);
         $message = new Zend_Amf_Value_Messaging_RemotingMessage();
         $message->operation = 'hello';
         $message->source = 'Zend_Amf_testException';
@@ -1084,7 +1084,7 @@ class Zend_Amf_ServerTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($response[0]->getData() instanceof Zend_Amf_Value_Messaging_ErrorMessage);
         $this->assertContains("Oops, exception!", $response[0]->getData()->faultString);
     }
-    
+
 }
 
 if (PHPUnit_MAIN_METHOD == "Zend_Amf_ServerTest::main") {
@@ -1205,37 +1205,37 @@ class Zend_Amf_testclass
     {
         throw new Exception('This exception should not be displayed');
     }
-    
+
     /**
-     * test if we can send an array as a paramater without it getting nested two   
+     * test if we can send an array as a paramater without it getting nested two
      * Used to test  ZF-5388
      */
     public function testSingleArrayParamater($inputArray){
-		if( $inputArray[0] == 'item1' ){
-			return true;
-		}
-		return false;
-    } 
+        if( $inputArray[0] == 'item1' ){
+            return true;
+        }
+        return false;
+    }
     /**
-     * This will crash if two arrays are not passed into the function. 
+     * This will crash if two arrays are not passed into the function.
      * Used to test  ZF-5388
      */
     public function testMultiArrayParamater($arrayOne, $arrayTwo)
     {
         return array_merge($arrayOne, $arrayTwo);
     }
-    
+
 }
 
 class Zend_Amf_testException
 {
-	public function __construct() {
-		throw new Exception("Oops, exception!");
-	}
-	
-	public function hello() {
-		return "hello";
-	}
+    public function __construct() {
+        throw new Exception("Oops, exception!");
+    }
+
+    public function hello() {
+        return "hello";
+    }
 }
 
 /**
@@ -1260,29 +1260,29 @@ class Zend_Amf_testclassPrivate
         return 'String: '. (string) $string;
     }
 
-    public function hello() 
+    public function hello()
     {
-	return "hello";
+        return "hello";
     }
 }
 
 /**
- * Example class for sending a session back to ActionScript. 
+ * Example class for sending a session back to ActionScript.
  */
 class Zend_Amf_testSession
 {
     /** Check if the session is available or create it. */
     public function __construct() {
-        if (!isset($_SESSION['count'])) { 
-			$_SESSION['count'] = 0;
-		}
-	}
-	
-	/** increment the current count session variable and return it's value */
+        if (!isset($_SESSION['count'])) {
+            $_SESSION['count'] = 0;
+        }
+    }
+
+    /** increment the current count session variable and return it's value */
     public function getCount()
     {
-    	$_SESSION['count']++;
-    	return $_SESSION['count']; 
+        $_SESSION['count']++;
+        return $_SESSION['count'];
     }
 }
 

+ 2 - 2
tests/Zend/Amf/ServiceA.php

@@ -1,9 +1,9 @@
 <?php
 class ServiceA {
-    function __construct() {        
+    function __construct() {
         //Construction...
     }
-    
+
     /**
      * @return string
      */

+ 2 - 2
tests/Zend/Amf/ServiceB.php

@@ -1,9 +1,9 @@
 <?php
 class ServiceB {
-    function __construct() {        
+    function __construct() {
         //Construction...
     }
-    
+
     /**
      * @return string
      */

+ 2 - 2
tests/Zend/Amf/ServiceC.php

@@ -1,9 +1,9 @@
 <?php
 class ServiceC {
-    function __construct() {        
+    function __construct() {
         //Construction...
     }
-    
+
     /**
      * @return string
      */

+ 24 - 24
tests/Zend/Amf/Value/ArrayCollectionTest.php

@@ -14,14 +14,14 @@ require_once 'Zend/Amf/Value/Messaging/ArrayCollection.php';
  */
 class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
 {
-    
-    
-    /** 
+
+
+    /**
      * Refrence to the array collection
      * @var Zend_Amf_Value_Message_ArrayCollection
      */
     protected $_arrayCollection;
-    
+
     /**
      * Data to be used to populate the ArrayCollection
      */
@@ -43,9 +43,9 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $data[] = array('foo' => 'foo1', 'bar' => 'bar1');
         $data[] = array('foo' => 'foo2', 'bar' => 'bar2');
         $this->_data = $data;
-        
+
     }
-    
+
     public function tearDown()
     {
         unset($this->_arrayCollection);
@@ -55,9 +55,9 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
     public function testConstructorArrayCollectionTwo()
     {
         $this->_arrayCollection = new Zend_Amf_Value_Messaging_ArrayCollectionTwo($this->_data);
-        $this->assertEquals('bar2', $this->_arrayCollection[1]['bar']);       
+        $this->assertEquals('bar2', $this->_arrayCollection[1]['bar']);
     }
-    
+
     /**
      * Check that the ArrayCollection can be accessed like a standard array.
      */
@@ -66,8 +66,8 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $this->_arrayCollection = new Zend_Amf_Value_Messaging_ArrayCollection($this->_data);
         $this->assertEquals('bar2', $this->_arrayCollection[1]['bar']);
     }
-    
-    /** 
+
+    /**
      * Check that we can get the count of the ArrayCollection
      */
     public function testCountable()
@@ -75,8 +75,8 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $this->_arrayCollection = new Zend_Amf_Value_Messaging_ArrayCollection($this->_data);
         $this->assertEquals(2, count($this->_arrayCollection));
     }
-    
-    /** 
+
+    /**
      * Test that we can foreach through the ArrayCollection
      */
     public function testIteratorArray()
@@ -89,16 +89,16 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         }
         $this->assertEquals(2, $count);
     }
-    
+
     /**
      * Test that we can alter an item based on it's offset
      */
     public function testOffsetExists()
     {
         $this->_arrayCollection = new Zend_Amf_Value_Messaging_ArrayCollection($this->_data);
-        $this->assertTrue($this->_arrayCollection->offsetExists(1));       
+        $this->assertTrue($this->_arrayCollection->offsetExists(1));
     }
-    
+
     /**
      * Check that you can set and get the changes to an offset key.
      */
@@ -109,9 +109,9 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $this->_arrayCollection->offsetSet(1,$data);
         $this->assertEquals($data, $this->_arrayCollection->offsetGet(1));
     }
-    
+
     /**
-     * Check that you can delete an item from the arraycollection based on key. 
+     * Check that you can delete an item from the arraycollection based on key.
      */
     public function testOffsetUnset()
     {
@@ -122,7 +122,7 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $this->_arrayCollection->offsetUnset(0);
         $this->assertEquals(1, count($this->_arrayCollection));
     }
-    
+
     /**
      * Check that you can transform an ArrayCollection into a standard array with iterator_to_array
      */
@@ -132,7 +132,7 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $standardArray = iterator_to_array($this->_arrayCollection);
         $this->assertTrue(is_array($standardArray));
     }
-    
+
     /**
      * Make sure that you can append more name values to the arraycollection
      */
@@ -142,9 +142,9 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $arrayCollectionTwo = new Zend_Amf_Value_Messaging_ArrayCollection();
         $arrayCollectionTwo->append(array('foo' => 'foo1', 'bar' => 'bar1'));
         $arrayCollectionTwo->append(array('foo' => 'foo2', 'bar' => 'bar2'));
-        $this->assertEquals($arrayCollectionTwo, $this->_arrayCollection);    
+        $this->assertEquals($arrayCollectionTwo, $this->_arrayCollection);
     }
-    
+
     /**
      * Test to make sure that when the iterator as data it is a valid iterator
      *
@@ -158,7 +158,7 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($this->_arrayCollection->valid());
     }
     */
-    
+
     /*
     public function testArrayIterator()
     {
@@ -175,10 +175,10 @@ class Zend_Amf_Value_ArrayCollectionTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($data3,$this->_arrayCollection->current());
         $this->_arrayCollection->rewind();
         $this->assertEquals($data0,$this->_arrayCollection->current());
-        
+
     }
     */
-    
+
 
 }
 

+ 13 - 13
tests/Zend/Amf/_files/services/My/ServiceA.php

@@ -1,14 +1,14 @@
-<?php
-class My_ServiceA {
-    function __construct() {        
-        //Construction...
-    }
-    
-    /**
-     * @return string
-     */
-    public function getMenu( )
-    {
-        return 'Service: myMenuA';
-    }
+<?php
+class My_ServiceA {
+    function __construct() {
+        //Construction...
+    }
+
+    /**
+     * @return string
+     */
+    public function getMenu( )
+    {
+        return 'Service: myMenuA';
+    }
 }

+ 13 - 13
tests/Zend/Amf/_files/services/ServiceC.php

@@ -1,14 +1,14 @@
-<?php
-class ServiceC {
-    function __construct() {        
-        //Construction...
-    }
-    
-    /**
-     * @return string
-     */
-    public function getMenu( )
-    {
-        return 'Service: MenuC';
-    }
+<?php
+class ServiceC {
+    function __construct() {
+        //Construction...
+    }
+
+    /**
+     * @return string
+     */
+    public function getMenu( )
+    {
+        return 'Service: MenuC';
+    }
 }