Skip to content
Snippets Groups Projects
Unverified Commit f2f94cf3 authored by Oleksii Korshenko's avatar Oleksii Korshenko Committed by GitHub
Browse files

Merge pull request #1733 from magento-engcom/2.2-develop-prs

Public Pull Requests

magento/magento2#12303 9764: exception message is wrong and misleading in findAccessorMethodName() of Magento\Framework\Reflection\NameFinder by @RomaKis

Fixed Public Issues

magento/magento2#9764 exception message is wrong and misleading in findAccessorMethodName() of Magento\Framework\Reflection\NameFinder
parents 1d5208bc a6f226f9
Branches
No related merge requests found
...@@ -99,8 +99,9 @@ class NameFinder ...@@ -99,8 +99,9 @@ class NameFinder
} else { } else {
throw new \LogicException( throw new \LogicException(
sprintf( sprintf(
'Property "%s" does not have corresponding setter in class "%s".', 'Property "%s" does not have accessor method "%s" in class "%s".',
$camelCaseProperty, $camelCaseProperty,
$accessorName,
$class->getName() $class->getName()
) )
); );
......
...@@ -27,7 +27,7 @@ class NameFinderTest extends \PHPUnit\Framework\TestCase ...@@ -27,7 +27,7 @@ class NameFinderTest extends \PHPUnit\Framework\TestCase
public function testGetSetterMethodName() public function testGetSetterMethodName()
{ {
$class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class);
$setterName = $this->nameFinder->getSetterMethodName($class, 'AttrName'); $setterName = $this->nameFinder->getSetterMethodName($class, 'AttrName');
$this->assertEquals("setAttrName", $setterName); $this->assertEquals("setAttrName", $setterName);
...@@ -37,21 +37,43 @@ class NameFinderTest extends \PHPUnit\Framework\TestCase ...@@ -37,21 +37,43 @@ class NameFinderTest extends \PHPUnit\Framework\TestCase
/** /**
* @expectedException \Exception * @expectedException \Exception
* @expectedExceptionMessageRegExp /Property "InvalidAttribute" does not have corresponding setter in class (.*?)/ * @codingStandardsIgnoreStart
* @expectedExceptionMessage Property "InvalidAttribute" does not have accessor method "setInvalidAttribute" in class "Magento\Framework\Reflection\Test\Unit\DataObject"
* @codingStandardsIgnoreEnd
*/ */
public function testGetSetterMethodNameInvalidAttribute() public function testGetSetterMethodNameInvalidAttribute()
{ {
$class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class);
$this->nameFinder->getSetterMethodName($class, 'InvalidAttribute'); $this->nameFinder->getSetterMethodName($class, 'InvalidAttribute');
} }
/** /**
* @expectedException \Exception * @expectedException \Exception
* @expectedExceptionMessageRegExp /Property "ActivE" does not have corresponding setter in class (.*?)/ * @codingStandardsIgnoreStart
* @expectedExceptionMessage Property "ActivE" does not have accessor method "setActivE" in class "Magento\Framework\Reflection\Test\Unit\DataObject"
* @codingStandardsIgnoreEnd
*/ */
public function testGetSetterMethodNameWrongCamelCasedAttribute() public function testGetSetterMethodNameWrongCamelCasedAttribute()
{ {
$class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class);
$this->nameFinder->getSetterMethodName($class, 'ActivE'); $this->nameFinder->getSetterMethodName($class, 'ActivE');
} }
/**
* @expectedException \LogicException
* @expectedExceptionMessage Property "Property" does not have accessor method "getProperty" in class "className".
*/
public function testFindAccessorMethodName()
{
$reflectionClass = $this->createMock(\Zend\Code\Reflection\ClassReflection::class);
$reflectionClass->expects($this->atLeastOnce())->method('hasMethod')->willReturn(false);
$reflectionClass->expects($this->atLeastOnce())->method('getName')->willReturn('className');
$this->nameFinder->findAccessorMethodName(
$reflectionClass,
'Property',
'getProperty',
'isProperty'
);
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment