Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ClassReaderDecoratorTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class ClassReaderDecoratorTest extends \PHPUnit\Framework\TestCase
11 {
15  private $model;
16 
20  private $classReaderMock;
21 
22  protected function setUp()
23  {
24  $this->classReaderMock = $this->getMockBuilder(\Magento\Framework\Code\Reader\ClassReader::class)
25  ->disableOriginalConstructor()
26  ->setMethods([])
27  ->getMock();
28  $this->model = new \Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator($this->classReaderMock);
29  }
30 
37  public function testGetConstructor($expectation, $className, $willReturn)
38  {
39  $this->classReaderMock->expects($this->once())
40  ->method('getConstructor')
41  ->with($className)
42  ->willReturn($willReturn);
43  $this->assertEquals(
44  $expectation,
45  $this->model->getConstructor($className)
46  );
47  }
48 
52  public function getConstructorDataProvider()
53  {
54  return [
55  [null, 'null', null],
56  [
57  [new ConstructorArgument(['name', 'type', 'isRequired', 'defaultValue'])],
58  'array',
59  [['name', 'type', 'isRequired', 'defaultValue']]
60  ]
61  ];
62  }
63 
64  public function testGetParents()
65  {
66  $stringArray = ['Parent_Class_Name1', 'Interface_1'];
67  $this->classReaderMock->expects($this->once())
68  ->method('getParents')
69  ->with('Child_Class_Name')
70  ->willReturn($stringArray);
71  $this->assertEquals($stringArray, $this->model->getParents('Child_Class_Name'));
72  }
73 }
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31