From ba58324f67aea91261a8d6d100d3a5951752b55a Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Thu, 20 Oct 2016 12:06:08 -0500 Subject: [PATCH] MAGETWO-58643: Refactor ObjectManager, Interception, Reflection Framework - address code review comments --- .../Reflection/Test/Unit/MethodsMapTest.php | 72 ++++++++++--------- .../Test/Unit/ServiceInputProcessorTest.php | 8 +-- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php index 35af774c7ba..67a372c4d33 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php @@ -86,44 +86,46 @@ class MethodsMapTest extends \PHPUnit_Framework_TestCase public function testGetMethodsMap() { + $data = [ + 'getMethodReturnType' => [ + 'type' => 'string', + 'isRequired' => true, + 'description' => null, + 'parameterCount' => 2, + ], + 'getMethodsMap' => [ + 'type' => 'array', + 'isRequired' => true, + 'description' => "<pre> Service methods' reflection data stored in cache as 'methodName' => " + . "'returnType' ex. [ 'create' => '\Magento\Customer\Api\Data\Customer', 'validatePassword' " + . "=> 'boolean' ] </pre>", + 'parameterCount' => 1, + ], + 'getMethodParams' => [ + 'type' => 'array', + 'isRequired' => true, + 'description' => null, + 'parameterCount' => 2 + ], + 'isMethodValidForDataField' => [ + 'type' => 'bool', + 'isRequired' => true, + 'description' => null, + 'parameterCount' => 2, + ], + 'isMethodReturnValueRequired' => [ + 'type' => 'bool', + 'isRequired' => true, + 'description' => null, + 'parameterCount' => 2, + ], + ]; $this->serializerMock->expects($this->once()) - ->method('serialize'); + ->method('serialize') + ->with($data); $methodsMap = $this->object->getMethodsMap(\Magento\Framework\Reflection\MethodsMap::class); $this->assertEquals( - [ - 'getMethodReturnType' => [ - 'type' => 'string', - 'isRequired' => true, - 'description' => null, - 'parameterCount' => 2, - ], - 'getMethodsMap' => [ - 'type' => 'array', - 'isRequired' => true, - 'description' => "<pre> Service methods' reflection data stored in cache as 'methodName' => " - . "'returnType' ex. [ 'create' => '\Magento\Customer\Api\Data\Customer', 'validatePassword' " - . "=> 'boolean' ] </pre>", - 'parameterCount' => 1, - ], - 'getMethodParams' => [ - 'type' => 'array', - 'isRequired' => true, - 'description' => null, - 'parameterCount' => 2 - ], - 'isMethodValidForDataField' => [ - 'type' => 'bool', - 'isRequired' => true, - 'description' => null, - 'parameterCount' => 2, - ], - 'isMethodReturnValueRequired' => [ - 'type' => 'bool', - 'isRequired' => true, - 'description' => null, - 'parameterCount' => 2, - ], - ], + $data, $methodsMap ); } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php index 4892c96a220..658755d38a4 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php @@ -100,13 +100,9 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase ); $serializerMock = $this->getMock(SerializerInterface::class); $serializerMock->method('serialize') - ->willReturnCallback(function ($data) { - return json_encode($data); - }); + ->willReturn('serializedData'); $serializerMock->method('unserialize') - ->willReturnCallback(function ($string) { - return json_decode($string, true); - }); + ->willReturn('unserializedData'); $objectManager->setBackwardCompatibleProperty( $this->methodsMap, 'serializer', -- GitLab