Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PhpScannerTest.php
Go to the documentation of this file.
1 <?php
7 
8 require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/Helper/Test.php';
9 require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/ElementFactory.php';
10 require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/Model/DoubleColon.php';
11 require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/Api/Data/SomeInterface.php';
12 
14 
15 class PhpScannerTest extends \PHPUnit\Framework\TestCase
16 {
20  protected $_model;
21 
25  protected $_testDir;
26 
30  protected $_testFiles = [];
31 
35  protected $_logMock;
36 
37  protected function setUp()
38  {
39  $this->_logMock = $this->createMock(\Magento\Setup\Module\Di\Compiler\Log\Log::class);
40  $this->_model = new \Magento\Setup\Module\Di\Code\Scanner\PhpScanner($this->_logMock, new TypeProcessor());
41  $this->_testDir = str_replace('\\', '/', realpath(__DIR__ . '/../../') . '/_files');
42  }
43 
44  public function testCollectEntities()
45  {
46  $this->_testFiles = [
47  $this->_testDir . '/app/code/Magento/SomeModule/Helper/Test.php',
48  $this->_testDir . '/app/code/Magento/SomeModule/Model/DoubleColon.php',
49  $this->_testDir . '/app/code/Magento/SomeModule/Api/Data/SomeInterface.php'
50  ];
51 
52  $this->_logMock->expects(
53  $this->at(0)
54  )->method(
55  'add'
56  )->with(
57  4,
58  'Magento\SomeModule\Module\Factory',
59  'Invalid Factory for nonexistent class Magento\SomeModule\Module in file ' . $this->_testFiles[0]
60  );
61  $this->_logMock->expects(
62  $this->at(1)
63  )->method(
64  'add'
65  )->with(
66  4,
67  'Magento\SomeModule\Element\Factory',
68  'Invalid Factory declaration for class Magento\SomeModule\Element in file ' . $this->_testFiles[0]
69  );
70 
71  $this->assertEquals(
72  ['\\' . \Magento\Eav\Api\Data\AttributeExtensionInterface::class],
73  $this->_model->collectEntities($this->_testFiles)
74  );
75  }
76 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60