From 1dbf181741ad65a6ef5aaed7dd1700d30c1a7e6c Mon Sep 17 00:00:00 2001 From: Joan He Date: Mon, 11 Jan 2016 18:15:17 -0600 Subject: [PATCH 1/5] MAGETWO-44484: Fatal memory allocation error in FactoryTest.php --- .../Framework/Data/Test/Unit/Form/Element/FactoryTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php index b63b3d2b557ca..f0cdd58e122ee 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/FactoryTest.php @@ -51,7 +51,9 @@ public function testCreatePositive($type) )->will( $this->returnValue($elementMock) ); - $this->assertSame($elementMock, $this->_factory->create($type)); + $element = $this->_factory->create($type); + $this->assertSame($elementMock, $element); + unset($elementMock, $element); } /** @@ -73,7 +75,9 @@ public function testCreatePositiveWithNotEmptyConfig($type) )->will( $this->returnValue($elementMock) ); - $this->assertSame($elementMock, $this->_factory->create($type, $config)); + $element = $this->_factory->create($type, $config); + $this->assertSame($elementMock, $element); + unset($elementMock, $element); } /** From c6af48555c83e28576024ab841ea4d5e67806f6f Mon Sep 17 00:00:00 2001 From: Joan He Date: Tue, 12 Jan 2016 13:10:58 -0600 Subject: [PATCH 2/5] MAGETWO-47639: [Github] Not all files are pre-compiled #2888 - Fixed single tenant compiler --- app/code/Magento/Cron/etc/di.xml | 8 ++ .../Framework/Config/Reader/Filesystem.php | 10 ++ .../Console/Command/DiCompileCommand.php | 13 +-- .../Di/App/Task/Operation/ProxyGenerator.php | 31 ++----- .../Task/Operation/RepositoryGenerator.php | 31 ++----- .../ServiceDataAttributesGenerator.php | 33 +++---- .../Di/Code/Scanner/ConfigurationScanner.php | 48 ++++++++++ .../Module/Di/App/Task/ProxyGeneratorTest.php | 81 +++++----------- .../Di/App/Task/RepositoryGeneratorTest.php | 93 +++++++------------ .../ServiceDataAttributesGeneratorTest.php | 90 ++++++------------ .../Code/Scanner/ConfigurationScannerTest.php | 64 +++++++++++++ 11 files changed, 251 insertions(+), 251 deletions(-) create mode 100644 setup/src/Magento/Setup/Module/Di/Code/Scanner/ConfigurationScanner.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index ae600be3c5c8a..db9161d26099f 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -36,4 +36,12 @@ + + + + + + + + diff --git a/lib/internal/Magento/Framework/Config/Reader/Filesystem.php b/lib/internal/Magento/Framework/Config/Reader/Filesystem.php index bbe3544318f84..e1b271f9bd0f1 100644 --- a/lib/internal/Magento/Framework/Config/Reader/Filesystem.php +++ b/lib/internal/Magento/Framework/Config/Reader/Filesystem.php @@ -67,6 +67,16 @@ class Filesystem implements \Magento\Framework\Config\ReaderInterface */ protected $validationState; + /** + * @var string + */ + protected $_defaultScope; + + /** + * @var string + */ + protected $_schemaFile; + /** * Constructor * diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 8843fb66c2111..963ae19576ac1 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -299,20 +299,11 @@ private function getOperationsConfiguration( } $operations = [ - OperationFactory::PROXY_GENERATOR => [ - 'paths' => $compiledPathsList['application'], - 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'], - 'excludePatterns' => $excludePatterns, - ], + OperationFactory::PROXY_GENERATOR => [], OperationFactory::REPOSITORY_GENERATOR => [ 'paths' => $compiledPathsList['application'], - 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'], - 'excludePatterns' => $excludePatterns, - ], - OperationFactory::DATA_ATTRIBUTES_GENERATOR => [ - 'paths' => $compiledPathsList['application'], - 'filePatterns' => $dataAttributesIncludePattern ], + OperationFactory::DATA_ATTRIBUTES_GENERATOR => [], OperationFactory::APPLICATION_CODE_GENERATOR => [ 'paths' => [ $compiledPathsList['application'], diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php index ebfec0635b8bb..f5c79fec02f2e 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php @@ -11,11 +11,6 @@ class ProxyGenerator implements OperationInterface { - /** - * @var Scanner\DirectoryScanner - */ - private $directoryScanner; - /** * @var Scanner\XmlScanner */ @@ -27,18 +22,23 @@ class ProxyGenerator implements OperationInterface private $data; /** - * @param Scanner\DirectoryScanner $directoryScanner + * @var Scanner\ConfigurationScanner + */ + private $configurationScanner; + + /** * @param Scanner\XmlScanner $proxyScanner + * @param Scanner\ConfigurationScanner $configurationScanner * @param array $data */ public function __construct( - Scanner\DirectoryScanner $directoryScanner, Scanner\XmlScanner $proxyScanner, + \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner $configurationScanner, $data = [] ) { - $this->directoryScanner = $directoryScanner; $this->proxyScanner = $proxyScanner; $this->data = $data; + $this->configurationScanner = $configurationScanner; } /** @@ -48,19 +48,8 @@ public function __construct( */ public function doOperation() { - if (array_diff(array_keys($this->data), ['filePatterns', 'paths', 'excludePatterns']) - !== array_diff(['filePatterns', 'paths', 'excludePatterns'], array_keys($this->data))) { - return; - } - - $files = []; - foreach ($this->data['paths'] as $path) { - $files = array_merge_recursive( - $files, - $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns']) - ); - } - $proxies = $this->proxyScanner->collectEntities($files['di']); + $files = $this->configurationScanner->scan('di.xml'); + $proxies = $this->proxyScanner->collectEntities($files); foreach ($proxies as $entityName) { class_exists($entityName); } diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php index 60d1159661528..2f51b34a11187 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php @@ -12,11 +12,6 @@ class RepositoryGenerator implements OperationInterface { - /** - * @var Scanner\DirectoryScanner - */ - private $directoryScanner; - /** * @var Scanner\RepositoryScanner */ @@ -33,21 +28,26 @@ class RepositoryGenerator implements OperationInterface private $classesScanner; /** - * @param Scanner\DirectoryScanner $directoryScanner + * @var Scanner\ConfigurationScanner + */ + private $configurationScanner; + + /** * @param ClassesScanner $classesScanner * @param Scanner\RepositoryScanner $repositoryScanner + * @param Scanner\ConfigurationScanner $configurationScanner * @param array $data */ public function __construct( - Scanner\DirectoryScanner $directoryScanner, ClassesScanner $classesScanner, Scanner\RepositoryScanner $repositoryScanner, + \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner $configurationScanner, $data = [] ) { - $this->directoryScanner = $directoryScanner; $this->repositoryScanner = $repositoryScanner; $this->data = $data; $this->classesScanner = $classesScanner; + $this->configurationScanner = $configurationScanner; } /** @@ -57,23 +57,12 @@ public function __construct( */ public function doOperation() { - if (array_diff(array_keys($this->data), ['filePatterns', 'paths', 'excludePatterns']) - !== array_diff(['filePatterns', 'paths', 'excludePatterns'], array_keys($this->data))) { - return; - } - foreach ($this->data['paths'] as $path) { $this->classesScanner->getList($path); } $this->repositoryScanner->setUseAutoload(false); - $files = []; - foreach ($this->data['paths'] as $path) { - $files = array_merge_recursive( - $files, - $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns']) - ); - } - $repositories = $this->repositoryScanner->collectEntities($files['di']); + $files = $this->configurationScanner->scan('di.xml'); + $repositories = $this->repositoryScanner->collectEntities($files); foreach ($repositories as $entityName) { class_exists($entityName); } diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ServiceDataAttributesGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ServiceDataAttributesGenerator.php index 0a28df86d27fc..2f80abd296d06 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ServiceDataAttributesGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ServiceDataAttributesGenerator.php @@ -16,11 +16,6 @@ */ class ServiceDataAttributesGenerator implements OperationInterface { - /** - * @var Scanner\DirectoryScanner - */ - private $directoryScanner; - /** * @var Scanner\ServiceDataAttributesScanner */ @@ -32,18 +27,23 @@ class ServiceDataAttributesGenerator implements OperationInterface private $data; /** - * @param Scanner\DirectoryScanner $directoryScanner - * @param Scanner\ServiceDataAttributesScanner $repositoryScanner + * @var Scanner\ConfigurationScanner + */ + private $configurationScanner; + + /** + * @param Scanner\ServiceDataAttributesScanner $serviceDataAttributesScanner + * @param Scanner\ConfigurationScanner $configurationScanner * @param array $data */ public function __construct( - Scanner\DirectoryScanner $directoryScanner, - Scanner\ServiceDataAttributesScanner $repositoryScanner, + Scanner\ServiceDataAttributesScanner $serviceDataAttributesScanner, + \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner $configurationScanner, $data = [] ) { - $this->directoryScanner = $directoryScanner; - $this->serviceDataAttributesScanner = $repositoryScanner; + $this->serviceDataAttributesScanner = $serviceDataAttributesScanner; $this->data = $data; + $this->configurationScanner = $configurationScanner; } /** @@ -53,15 +53,8 @@ public function __construct( */ public function doOperation() { - if (array_diff(array_keys($this->data), ['filePatterns', 'paths']) - !== array_diff(['filePatterns', 'paths'], array_keys($this->data))) { - return; - } - $files = []; - foreach ($this->data['paths'] as $path) { - $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'])); - } - $repositories = $this->serviceDataAttributesScanner->collectEntities($files['extension_attributes']); + $files = $this->configurationScanner->scan('extension_attributes.xml'); + $repositories = $this->serviceDataAttributesScanner->collectEntities($files); foreach ($repositories as $entityName) { class_exists($entityName); } diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/ConfigurationScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/ConfigurationScanner.php new file mode 100644 index 0000000000000..90aed20512528 --- /dev/null +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/ConfigurationScanner.php @@ -0,0 +1,48 @@ +fileResolver = $fileResolver; + $this->areaList = $areaList; + } + + /** + * Scan configuration files + * + * @param string $fileName + * + * @return array array of paths to the configuration files + */ + public function scan($fileName) + { + $files = []; + $areaCodes = array_merge( + ['primary', Area::AREA_GLOBAL], + $this->areaList->getCodes() + ); + foreach ($areaCodes as $area) { + $files = array_merge_recursive( + $files, + $this->fileResolver->get($fileName, $area)->toArray() + ); + } + return array_keys($files); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php index c721973f615ef..ac0ecfc74dbf7 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php @@ -13,83 +13,52 @@ class ProxyGeneratorTest extends \PHPUnit_Framework_TestCase { /** - * @var Scanner\DirectoryScanner | \PHPUnit_Framework_MockObject_MockObject + * @var Scanner\XmlScanner | \PHPUnit_Framework_MockObject_MockObject */ - private $directoryScannerMock; + private $proxyScannerMock; /** - * @var Scanner\XmlScanner | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner | \PHPUnit_Framework_MockObject_MockObject */ - private $proxyScannerMock; + private $configurationScannerMock; + + /** + * @var \Magento\Setup\Module\Di\App\Task\Operation\ProxyGenerator + */ + private $model; protected function setUp() { - $this->directoryScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner') + $this->proxyScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\XmlScanner') ->disableOriginalConstructor() ->getMock(); - $this->proxyScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\XmlScanner') + + $this->configurationScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner') ->disableOriginalConstructor() ->getMock(); - } - /** - * @param array $data - * - * @dataProvider doOperationWrongDataDataProvider - */ - public function testDoOperationWrongData($data) - { - $model = new ProxyGenerator( - $this->directoryScannerMock, - $this->proxyScannerMock, - $data + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $objectManagerHelper->getObject( + 'Magento\Setup\Module\Di\App\Task\Operation\ProxyGenerator', + [ + 'proxyScanner' => $this->proxyScannerMock, + 'configurationScanner' => $this->configurationScannerMock, + ] ); - - $this->directoryScannerMock->expects($this->never()) - ->method('scan'); - $this->proxyScannerMock->expects($this->never()) - ->method('collectEntities'); - - $this->assertEmpty($model->doOperation()); - } - - /** - * @return array - */ - public function doOperationWrongDataDataProvider() - { - return [ - [[]], - [['filePatterns' => ['php' => '*.php']]], - [['path' => 'path']], - ]; } public function testDoOperation() { - $data = [ - 'paths' => ['path/to/app'], - 'filePatterns' => ['di' => 'di.xml'], - 'excludePatterns' => ['/\/Test\//'], - ]; - $files = ['di' => []]; - $model = new ProxyGenerator( - $this->directoryScannerMock, - $this->proxyScannerMock, - $data - ); - - $this->directoryScannerMock->expects($this->once()) + $files = ['file1', 'file2']; + $this->configurationScannerMock->expects($this->once()) ->method('scan') - ->with( - $data['paths'][0], - $data['filePatterns'] - )->willReturn($files); + ->with('di.xml') + ->willReturn($files); $this->proxyScannerMock->expects($this->once()) ->method('collectEntities') - ->with($files['di']) + ->with($files) ->willReturn([]); - $this->assertEmpty($model->doOperation()); + $this->model->doOperation(); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php index 626ccfbe71346..cf8ab935db943 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php @@ -12,11 +12,6 @@ class RepositoryGeneratorTest extends \PHPUnit_Framework_TestCase { - /** - * @var Scanner\DirectoryScanner | \PHPUnit_Framework_MockObject_MockObject - */ - private $directoryScannerMock; - /** * @var Scanner\RepositoryScanner | \PHPUnit_Framework_MockObject_MockObject */ @@ -27,81 +22,59 @@ class RepositoryGeneratorTest extends \PHPUnit_Framework_TestCase */ private $classesScannerMock; + + /** + * @var \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner | \PHPUnit_Framework_MockObject_MockObject + */ + private $configurationScannerMock; + + /** + * @var \Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator + */ + private $model; + protected function setUp() { - $this->directoryScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner') - ->setMethods([]) - ->disableOriginalConstructor() - ->getMock(); $this->repositoryScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\RepositoryScanner') - ->setMethods([]) ->disableOriginalConstructor() ->getMock(); $this->classesScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Reader\ClassesScanner') - ->setMethods([]) ->disableOriginalConstructor() ->getMock(); - } - - /** - * @dataProvider wrongDataDataProvider - */ - public function testDoOperationEmptyData($wrongData) - { - $model = new RepositoryGenerator( - $this->directoryScannerMock, - $this->classesScannerMock, - $this->repositoryScannerMock, - $wrongData + $this->configurationScannerMock = $this->getMockBuilder( + 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner' + )->disableOriginalConstructor() + ->getMock(); + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $objectManagerHelper->getObject( + 'Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator', + [ + 'repositoryScanner' => $this->repositoryScannerMock, + 'classesScanner' => $this->classesScannerMock, + 'configurationScanner' => $this->configurationScannerMock, + 'data' => ['paths' => ['path/to/app']] + ] ); - - $this->assertNull($model->doOperation()); - } - - /** - * @return array - */ - public function wrongDataDataProvider() - { - return [ - [[]], - [['filePatterns' => ['php' => '*.php']]], - [['path' => 'path']] - ]; } - public function testDoOperationEmptyRepositories() + public function testDoOperation() { - $data = [ - 'paths' => ['path/to/app'], - 'filePatterns' => ['di' => 'di.xml'], - 'excludePatterns' => ['/\/Test\//'], - ]; - $files = ['di' => []]; - $model = new RepositoryGenerator( - $this->directoryScannerMock, - $this->classesScannerMock, - $this->repositoryScannerMock, - $data - ); - $this->classesScannerMock->expects($this->once()) ->method('getList') - ->with($data['paths'][0]); - $this->directoryScannerMock->expects($this->once()) - ->method('scan') - ->with( - $data['paths'][0], - $data['filePatterns'] - )->willReturn($files); + ->with('path/to/app'); $this->repositoryScannerMock->expects($this->once()) ->method('setUseAutoload') ->with(false); + $files = ['file1', 'file2']; + $this->configurationScannerMock->expects($this->once()) + ->method('scan') + ->with('di.xml') + ->willReturn($files); $this->repositoryScannerMock->expects($this->once()) ->method('collectEntities') - ->with($files['di']) + ->with($files) ->willReturn([]); - $this->assertEmpty($model->doOperation()); + $this->model->doOperation(); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php index b1b01608ea21d..3d97c1083927f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ServiceDataAttributesGeneratorTest.php @@ -6,7 +6,6 @@ namespace Magento\Setup\Test\Unit\Module\Di\App\Task; -use Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator; use Magento\Setup\Module\Di\Code\Scanner; /** @@ -15,85 +14,52 @@ class ServiceDataAttributesGeneratorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner | \PHPUnit_Framework_MockObject_MockObject */ - private $directoryScannerMock; - + private $configurationScannerMock; + /** * @var \Magento\Setup\Module\Di\Code\Scanner\ServiceDataAttributesScanner|\PHPUnit_Framework_MockObject_MockObject */ private $serviceDataAttributesScannerMock; - protected function setUp() - { - $this->directoryScannerMock = $this->getMock( - 'Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner', - [], - [], - '', - false - ); - $this->serviceDataAttributesScannerMock = $this->getMock( - 'Magento\Setup\Module\Di\Code\Scanner\ServiceDataAttributesScanner', - [], - [], - '', - false - ); - } - /** - * @param $data array - * @dataProvider doOperationDataProvider + * @var \Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator */ - public function testDoOperationEmptyData($data) - { - $model = new ServiceDataAttributesGenerator( - $this->directoryScannerMock, - $this->serviceDataAttributesScannerMock, - $data - ); - $this->directoryScannerMock->expects($this->never())->method('scan'); + private $model; - $model->doOperation(); - } - - /** - * @return array - */ - public function doOperationDataProvider() + protected function setUp() { - return [ - [[]], - [['filePatterns' => ['php' => '*.php']]], - [['path' => 'path']] - ]; + $this->configurationScannerMock = $this->getMockBuilder( + 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner' + )->disableOriginalConstructor() + ->getMock(); + $this->serviceDataAttributesScannerMock = $this->getMockBuilder( + 'Magento\Setup\Module\Di\Code\Scanner\ServiceDataAttributesScanner' + )->disableOriginalConstructor() + ->getMock(); + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $objectManagerHelper->getObject( + 'Magento\Setup\Module\Di\App\Task\Operation\ServiceDataAttributesGenerator', + [ + 'serviceDataAttributesScanner' => $this->serviceDataAttributesScannerMock, + 'configurationScanner' => $this->configurationScannerMock, + ] + ); } public function testDoOperation() { - $data = [ - 'paths' => ['path/to/app'], - 'filePatterns' => ['di' => 'di.xml'], - ]; - $files = ['extension_attributes' => []]; - $model = new ServiceDataAttributesGenerator( - $this->directoryScannerMock, - $this->serviceDataAttributesScannerMock, - $data - ); - - $this->directoryScannerMock->expects($this->once()) + $files = ['file1', 'file2']; + $this->configurationScannerMock->expects($this->once()) ->method('scan') - ->with( - $data['paths'][0], - $data['filePatterns'] - )->willReturn($files); + ->with('extension_attributes.xml') + ->willReturn($files); $this->serviceDataAttributesScannerMock->expects($this->once()) ->method('collectEntities') - ->with($files['extension_attributes']) + ->with($files) ->willReturn([]); - $model->doOperation(); + $this->model->doOperation(); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php new file mode 100644 index 0000000000000..32e0398890464 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/ConfigurationScannerTest.php @@ -0,0 +1,64 @@ +fileResolverMock = $this->getMockBuilder('Magento\Framework\App\Config\FileResolver') + ->disableOriginalConstructor() + ->getMock(); + + $this->areaListMock = $this->getMockBuilder('Magento\Framework\App\AreaList') + ->disableOriginalConstructor() + ->getMock(); + + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $objectManagerHelper->getObject( + 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner', + [ + 'fileResolver' => $this->fileResolverMock, + 'areaList' => $this->areaListMock, + ] + ); + } + + public function testScan() + { + $codes = ['code1', 'code2']; + $iteratorMock = $this->getMockBuilder('Magento\Framework\Config\FileIterator') + ->disableOriginalConstructor() + ->getMock(); + $this->areaListMock->expects($this->once()) + ->method('getCodes') + ->willReturn($codes); + $counts = count($codes) + 2; + $this->fileResolverMock->expects($this->exactly($counts)) + ->method('get') + ->willReturn($iteratorMock); + $files = ['file1' => 'onefile', 'file2' => 'anotherfile']; + $iteratorMock->expects($this->exactly($counts)) + ->method('toArray') + ->willReturn($files); + $this->assertEquals(array_keys($files), $this->model->scan('di.xml')); + } +} From b55284e4cf69a79c726d6bacebac2e8f977348ad Mon Sep 17 00:00:00 2001 From: Joan He Date: Tue, 12 Jan 2016 13:28:59 -0600 Subject: [PATCH 3/5] MAGETWO-47639: [Github] Not all files are pre-compiled #2888 - Fixed multi-tenant compiler --- .../Setup/Console/Command/DiCompileMultiTenantCommand.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php index ad5eb755281cf..fc5eb973944b5 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php @@ -260,6 +260,9 @@ public function generateCode($generationDir, $fileExcludePatterns, $input) $directoryScanner->scan($codeScanDir, $filePatterns, $fileExcludePatterns) ); } + $this->files['di'][] = $this->directoryList->getPath( + \Magento\Framework\App\Filesystem\DirectoryList::CONFIG + ) . '/di.xml'; $this->files['additional'] = [$input->getOption(self::INPUT_KEY_EXTRA_CLASSES_FILE)]; $repositoryScanner = new Scanner\RepositoryScanner(); $repositories = $repositoryScanner->collectEntities($this->files['di']); From 610432671efabb30e3f89e64016007bcdc8bd7a7 Mon Sep 17 00:00:00 2001 From: Joan He Date: Wed, 13 Jan 2016 08:48:58 -0600 Subject: [PATCH 4/5] MAGETWO-47639: [Github] Not all files are pre-compiled #2888 - Fixed static test failures --- .../Setup/Console/Command/DiCompileCommand.php | 12 ++---------- .../Unit/Module/Di/App/Task/ProxyGeneratorTest.php | 5 +++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 963ae19576ac1..b9dbc3aebbda2 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -161,15 +161,9 @@ protected function execute(InputInterface $input, OutputInterface $output) 'application' => $excludedModulePaths, 'framework' => $excludedLibraryPaths ]; - $dataAttributesIncludePattern = [ - 'extension_attributes' => '/\/etc\/([a-zA-Z_]*\/extension_attributes|extension_attributes)\.xml$/' - ]; $this->configureObjectManager($output); - $operations = $this->getOperationsConfiguration( - $compiledPathsList, - $dataAttributesIncludePattern - ); + $operations = $this->getOperationsConfiguration($compiledPathsList); try { $this->cleanupFilesystem( @@ -286,12 +280,10 @@ private function configureObjectManager(OutputInterface $output) * Returns operations configuration * * @param array $compiledPathsList - * @param array $dataAttributesIncludePattern * @return array */ private function getOperationsConfiguration( - array $compiledPathsList, - array $dataAttributesIncludePattern + array $compiledPathsList ) { $excludePatterns = []; foreach ($this->excludedPathsList as $excludedPaths) { diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php index ac0ecfc74dbf7..1a1382b87a65d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php @@ -33,8 +33,9 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->configurationScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner') - ->disableOriginalConstructor() + $this->configurationScannerMock = $this->getMockBuilder( + 'Magento\Setup\Module\Di\Code\Scanner\ConfigurationScanner' + )->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); From 8b83ff00439f24712915632739a3dc86564e07d6 Mon Sep 17 00:00:00 2001 From: Joan He Date: Wed, 13 Jan 2016 09:26:54 -0600 Subject: [PATCH 5/5] MAGETWO-47639: [Github] Not all files are pre-compiled #2888 - Fixed integration tests --- app/code/Magento/Cron/etc/di.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index db9161d26099f..0b78824ef4807 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -39,8 +39,7 @@ - - +