Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CompositeScannerTest.php
Go to the documentation of this file.
1 <?php
7 
8 class CompositeScannerTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_model;
14 
15  protected function setUp()
16  {
17  $this->_model = new \Magento\Setup\Module\Di\Code\Scanner\CompositeScanner();
18  }
19 
20  public function testScan()
21  {
22  $phpFiles = ['one/file/php', 'two/file/php'];
23  $configFiles = ['one/file/config', 'two/file/config'];
24  $files = ['php' => $phpFiles, 'config' => $configFiles];
25 
26  $scannerPhp = $this->createMock(\Magento\Setup\Module\Di\Code\Scanner\ScannerInterface::class);
27  $scannerXml = $this->createMock(\Magento\Setup\Module\Di\Code\Scanner\ScannerInterface::class);
28 
29  $scannerPhpExpected = ['Model_OneProxy', 'Model_TwoFactory'];
30  $scannerXmlExpected = ['Model_OneProxy', 'Model_ThreeFactory'];
31  $scannerPhp->expects(
32  $this->once()
33  )->method(
34  'collectEntities'
35  )->with(
36  $phpFiles
37  )->will(
38  $this->returnValue($scannerPhpExpected)
39  );
40 
41  $scannerXml->expects(
42  $this->once()
43  )->method(
44  'collectEntities'
45  )->with(
46  $configFiles
47  )->will(
48  $this->returnValue($scannerXmlExpected)
49  );
50 
51  $this->_model->addChild($scannerPhp, 'php');
52  $this->_model->addChild($scannerXml, 'config');
53 
54  $actual = $this->_model->collectEntities($files);
55  $expected = [$scannerPhpExpected, $scannerXmlExpected];
56 
57  $this->assertEquals($expected, array_values($actual));
58  }
59 }
foreach($appDirs as $dir) $files