From 2f2cafee687d81d95854b1629ef8eec7c5a4e548 Mon Sep 17 00:00:00 2001 From: Artsiom Bruneuski Date: Sat, 6 Oct 2018 17:26:58 +0200 Subject: [PATCH] Was added description to exceptions, annotations to properties and classes. Implemented validation of exception message in unit test --- .../Communication/Config/Validator.php | 2 +- .../Framework/Reflection/MethodsMap.php | 8 ++++---- .../Communication/Config/ValidatorTest.php | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/internal/Magento/Framework/Communication/Config/Validator.php b/lib/internal/Magento/Framework/Communication/Config/Validator.php index 73d245d79e111..f08c3700a33ba 100644 --- a/lib/internal/Magento/Framework/Communication/Config/Validator.php +++ b/lib/internal/Magento/Framework/Communication/Config/Validator.php @@ -121,7 +121,7 @@ public function validateResponseHandlersType($serviceName, $methodName, $handler * @param string $typeName * @return $this * @throws \Exception In case when type is invalid - * @throws \InvalidArgumentException +` * @throws \InvalidArgumentException if methods don't have annotation */ protected function validateType($typeName) { diff --git a/lib/internal/Magento/Framework/Reflection/MethodsMap.php b/lib/internal/Magento/Framework/Reflection/MethodsMap.php index 77015be8437a0..6b0ddfbfc2127 100644 --- a/lib/internal/Magento/Framework/Reflection/MethodsMap.php +++ b/lib/internal/Magento/Framework/Reflection/MethodsMap.php @@ -94,8 +94,8 @@ public function getMethodReturnType($typeName, $methodName) * 'validatePassword' => 'boolean' * ] * - * @throws \InvalidArgumentException - * @throws \ReflectionException + * @throws \InvalidArgumentException if methods don't have annotation + * @throws \ReflectionException for missing DocBock or invalid reflection class */ public function getMethodsMap($interfaceName) { @@ -150,8 +150,8 @@ public function getMethodParams($serviceClassName, $serviceMethodName) * * @param string $interfaceName * @return array - * @throws \ReflectionException - * @throws \InvalidArgumentException + * @throws \ReflectionException for missing DocBock or invalid reflection class + * @throws \InvalidArgumentException if methods don't have annotation */ private function getMethodMapViaReflection($interfaceName) { diff --git a/lib/internal/Magento/Framework/Test/Unit/Communication/Config/ValidatorTest.php b/lib/internal/Magento/Framework/Test/Unit/Communication/Config/ValidatorTest.php index c440d39f0188b..36e43de928019 100644 --- a/lib/internal/Magento/Framework/Test/Unit/Communication/Config/ValidatorTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/Communication/Config/ValidatorTest.php @@ -1,14 +1,27 @@ method('getMethodsMap') ->will($this->throwException(new \InvalidArgumentException('message', 333))); - $this->typeProcessor = $this->createMock(TypeProcessor::class); $this->typeProcessor->expects(static::any()) ->method('isTypeSimple') @@ -33,6 +45,7 @@ public function setUp() /** * @expectedException \LogicException * @expectedExceptionCode 333 + * @expectedExceptionMessage Response schema definition has service class with wrong annotated methods */ public function testValidateResponseSchemaType() { @@ -44,6 +57,7 @@ public function testValidateResponseSchemaType() /** * @expectedException \LogicException * @expectedExceptionCode 333 + * @expectedExceptionMessage Request schema definition has service class with wrong annotated methods */ public function testValidateRequestSchemaType() {