Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RepositoryGeneratorTest.php
Go to the documentation of this file.
1 <?php
8 
12 
13 class RepositoryGeneratorTest extends \PHPUnit\Framework\TestCase
14 {
18  private $repositoryScannerMock;
19 
23  private $classesScannerMock;
24 
28  private $configurationScannerMock;
29 
33  private $model;
34 
35  protected function setUp()
36  {
37  $this->repositoryScannerMock =
38  $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Scanner\RepositoryScanner::class)
39  ->disableOriginalConstructor()
40  ->getMock();
41  $this->classesScannerMock = $this->getMockBuilder(\Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class)
42  ->disableOriginalConstructor()
43  ->getMock();
44  $this->configurationScannerMock = $this->getMockBuilder(
45  \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner::class
46  )->disableOriginalConstructor()
47  ->getMock();
48  $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
49  $this->model = $objectManagerHelper->getObject(
50  \Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator::class,
51  [
52  'repositoryScanner' => $this->repositoryScannerMock,
53  'classesScanner' => $this->classesScannerMock,
54  'configurationScanner' => $this->configurationScannerMock,
55  'data' => ['paths' => ['path/to/app']]
56  ]
57  );
58  }
59 
60  public function testDoOperation()
61  {
62  $this->classesScannerMock->expects($this->once())
63  ->method('getList')
64  ->with('path/to/app');
65  $this->repositoryScannerMock->expects($this->once())
66  ->method('setUseAutoload')
67  ->with(false);
68  $files = ['file1', 'file2'];
69  $this->configurationScannerMock->expects($this->once())
70  ->method('scan')
71  ->with('di.xml')
72  ->willReturn($files);
73  $this->repositoryScannerMock->expects($this->once())
74  ->method('collectEntities')
75  ->with($files)
76  ->willReturn([]);
77 
78  $this->model->doOperation();
79  }
80 }
foreach($appDirs as $dir) $files