Skip to content

Commit 2f2cafe

Browse files
ArtsiomBruneuskigelanivishal
authored andcommitted
Was added description to exceptions, annotations to properties and classes. Implemented validation of exception message in unit test
1 parent a20968d commit 2f2cafe

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

lib/internal/Magento/Framework/Communication/Config/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function validateResponseHandlersType($serviceName, $methodName, $handler
121121
* @param string $typeName
122122
* @return $this
123123
* @throws \Exception In case when type is invalid
124-
* @throws \InvalidArgumentException
124+
` * @throws \InvalidArgumentException if methods don't have annotation
125125
*/
126126
protected function validateType($typeName)
127127
{

lib/internal/Magento/Framework/Reflection/MethodsMap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public function getMethodReturnType($typeName, $methodName)
9494
* 'validatePassword' => 'boolean'
9595
* ]
9696
* </pre>
97-
* @throws \InvalidArgumentException
98-
* @throws \ReflectionException
97+
* @throws \InvalidArgumentException if methods don't have annotation
98+
* @throws \ReflectionException for missing DocBock or invalid reflection class
9999
*/
100100
public function getMethodsMap($interfaceName)
101101
{
@@ -150,8 +150,8 @@ public function getMethodParams($serviceClassName, $serviceMethodName)
150150
*
151151
* @param string $interfaceName
152152
* @return array
153-
* @throws \ReflectionException
154-
* @throws \InvalidArgumentException
153+
* @throws \ReflectionException for missing DocBock or invalid reflection class
154+
* @throws \InvalidArgumentException if methods don't have annotation
155155
*/
156156
private function getMethodMapViaReflection($interfaceName)
157157
{

lib/internal/Magento/Framework/Test/Unit/Communication/Config/ValidatorTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
26
namespace Magento\Framework\Test\Unit\Communication\Config;
37

4-
58
use Magento\Framework\Communication\Config\Validator;
69
use Magento\Framework\Reflection\MethodsMap;
710
use Magento\Framework\Reflection\TypeProcessor;
811

12+
/**
13+
* Unit test for \Magento\Framework\Communication\Config\Validator class
14+
*/
915
class ValidatorTest extends \PHPUnit\Framework\TestCase
1016
{
17+
/**
18+
* @var TypeProcessor|\PHPUnit_Framework_MockObject_MockObject
19+
*/
1120
protected $typeProcessor;
21+
22+
/**
23+
* @var MethodsMap|\PHPUnit_Framework_MockObject_MockObject
24+
*/
1225
protected $methodsMap;
1326

1427
public function setUp()
@@ -19,7 +32,6 @@ public function setUp()
1932
->method('getMethodsMap')
2033
->will($this->throwException(new \InvalidArgumentException('message', 333)));
2134

22-
2335
$this->typeProcessor = $this->createMock(TypeProcessor::class);
2436
$this->typeProcessor->expects(static::any())
2537
->method('isTypeSimple')
@@ -33,6 +45,7 @@ public function setUp()
3345
/**
3446
* @expectedException \LogicException
3547
* @expectedExceptionCode 333
48+
* @expectedExceptionMessage Response schema definition has service class with wrong annotated methods
3649
*/
3750
public function testValidateResponseSchemaType()
3851
{
@@ -44,6 +57,7 @@ public function testValidateResponseSchemaType()
4457
/**
4558
* @expectedException \LogicException
4659
* @expectedExceptionCode 333
60+
* @expectedExceptionMessage Request schema definition has service class with wrong annotated methods
4761
*/
4862
public function testValidateRequestSchemaType()
4963
{

0 commit comments

Comments
 (0)