Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NameFinderTest.php
Go to the documentation of this file.
1 <?php
6 // @codingStandardsIgnoreStart
8 
9 use Zend\Code\Reflection\ClassReflection;
10 
14 class NameFinderTest extends \PHPUnit\Framework\TestCase
15 {
17  protected $nameFinder;
18 
22  protected function setUp()
23  {
24  $this->nameFinder = new \Magento\Framework\Reflection\NameFinder();
25  }
26 
27  public function testGetSetterMethodName()
28  {
29  $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class);
30  $setterName = $this->nameFinder->getSetterMethodName($class, 'AttrName');
31  $this->assertEquals("setAttrName", $setterName);
32 
33  $booleanSetterName = $this->nameFinder->getSetterMethodName($class, 'Active');
34  $this->assertEquals("setIsActive", $booleanSetterName);
35  }
36 
44  {
45  $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class);
46  $this->nameFinder->getSetterMethodName($class, 'InvalidAttribute');
47  }
48 
56  {
57  $class = new ClassReflection(\Magento\Framework\Reflection\Test\Unit\DataObject::class);
58  $this->nameFinder->getSetterMethodName($class, 'ActivE');
59  }
60 
65  public function testFindAccessorMethodName()
66  {
67  $reflectionClass = $this->createMock(\Zend\Code\Reflection\ClassReflection::class);
68  $reflectionClass->expects($this->atLeastOnce())->method('hasMethod')->willReturn(false);
69  $reflectionClass->expects($this->atLeastOnce())->method('getName')->willReturn('className');
70 
71  $this->nameFinder->findAccessorMethodName(
73  'Property',
74  'getProperty',
75  'isProperty'
76  );
77  }
78 }
$_option $_optionId $class
Definition: date.phtml:13
$reflectionClass
Definition: categories.php:25