diff --git a/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php b/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php index e8198f9ebb87a..8c908e25a9cb1 100644 --- a/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php +++ b/app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php @@ -17,9 +17,9 @@ class Iframe extends \Magento\Paypal\Block\Payflow\Link\Iframe * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Paypal\Helper\Hss $hssHelper - * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory * @param \Magento\Framework\Module\Dir\Reader $reader + * @param \Magento\Payment\Helper\Data $paymentData * @param array $data */ public function __construct( @@ -27,9 +27,9 @@ public function __construct( \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Paypal\Helper\Hss $hssHelper, - \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory, \Magento\Framework\Module\Dir\Reader $reader, + \Magento\Payment\Helper\Data $paymentData, array $data = [] ) { parent::__construct( @@ -37,9 +37,9 @@ public function __construct( $orderFactory, $checkoutSession, $hssHelper, - $paymentData, $readFactory, $reader, + $paymentData, $data ); $this->_isScopePrivate = false; diff --git a/app/code/Magento/Paypal/Block/Payflow/Link/Iframe.php b/app/code/Magento/Paypal/Block/Payflow/Link/Iframe.php index a735fe7988d6d..05028ace8b20a 100644 --- a/app/code/Magento/Paypal/Block/Payflow/Link/Iframe.php +++ b/app/code/Magento/Paypal/Block/Payflow/Link/Iframe.php @@ -22,9 +22,9 @@ class Iframe extends \Magento\Paypal\Block\Iframe * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Paypal\Helper\Hss $hssHelper - * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory * @param \Magento\Framework\Module\Dir\Reader $reader + * @param \Magento\Payment\Helper\Data $paymentData * @param array $data */ public function __construct( @@ -32,9 +32,9 @@ public function __construct( \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Paypal\Helper\Hss $hssHelper, - \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory, \Magento\Framework\Module\Dir\Reader $reader, + \Magento\Payment\Helper\Data $paymentData, array $data = [] ) { $this->_paymentData = $paymentData; diff --git a/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php b/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php index 565336219b1ac..7144a10cfded3 100644 --- a/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php @@ -90,9 +90,9 @@ public function testCheckIsScopePrivate() $this->orderFactoryMock, $this->checkoutSessionMock, $this->hssHelperMock, - $this->paymentDataMock, $this->readFactory, - $this->reader + $this->reader, + $this->paymentDataMock ); $this->assertFalse($block->isScopePrivate()); @@ -120,9 +120,9 @@ public function testGetTransactionUrlLive() $this->orderFactoryMock, $this->checkoutSessionMock, $this->hssHelperMock, - $this->paymentDataMock, $this->readFactory, - $this->reader + $this->reader, + $this->paymentDataMock ); $this->assertEquals($expected, $block->getTransactionUrl()); } @@ -149,9 +149,9 @@ public function testGetTransactionUrlTest() $this->orderFactoryMock, $this->checkoutSessionMock, $this->hssHelperMock, - $this->paymentDataMock, $this->readFactory, - $this->reader + $this->reader, + $this->paymentDataMock ); $this->assertEquals($expected, $block->getTransactionUrl()); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/FileResolverStub.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/FileResolverStub.php index 68a30311d4ae6..32546a6be9bc0 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/FileResolverStub.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/FileResolverStub.php @@ -14,15 +14,8 @@ class FileResolverStub implements \Magento\Framework\Config\FileResolverInterfac */ public function get($filename, $scope) { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $readDirectory = $objectManager->create( - 'Magento\Framework\Filesystem\Directory\Read', - [ - 'driver' => $objectManager->create('Magento\Framework\Filesystem\Driver\File'), - 'path' => realpath(__DIR__ . '/../../_files/etc'), - ] - ); - $paths = ['search_request_1.xml', 'search_request_2.xml']; - return new \Magento\Framework\Config\FileIterator($readDirectory, $paths); + $path = realpath(__DIR__ . '/../../_files/etc'); + $paths = [$path . '/search_request_1.xml', $path . '/search_request_2.xml']; + return new \Magento\Framework\Config\FileIterator(new \Magento\Framework\Filesystem\Driver\File, $paths); } } diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php index c1550e3a36502..7aec917a99dbb 100644 --- a/lib/internal/Magento/Framework/App/Utility/Files.php +++ b/lib/internal/Magento/Framework/App/Utility/Files.php @@ -1146,7 +1146,7 @@ public function classFileExists($class, &$path = '') $fullPath = $dir . $path; $trimmedFullPath = $dir . explode('/', $path, 3)[2]; if ($this->classFileExistsCheckContent($fullPath, $namespace, $className) - || $this->classFileExistsCheckContent($trimmedFullPath, $namespace, $class) + || $this->classFileExistsCheckContent($trimmedFullPath, $namespace, $className) ) { return true; } @@ -1159,7 +1159,7 @@ public function classFileExists($class, &$path = '') * * @param string $fullPath * @param string $namespace - * @param $className + * @param string $className * @return bool */ private function classFileExistsCheckContent($fullPath, $namespace, $className) diff --git a/lib/internal/Magento/Framework/Autoload/Populator.php b/lib/internal/Magento/Framework/Autoload/Populator.php index e3db5ac3512cb..165fa75ab439a 100644 --- a/lib/internal/Magento/Framework/Autoload/Populator.php +++ b/lib/internal/Magento/Framework/Autoload/Populator.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Autoload; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Component\ComponentRegistrar; +use Magento\Framework\Autoload\AutoloaderInterface; use Magento\Framework\Filesystem\FileResolver; /** @@ -18,22 +18,16 @@ class Populator /** * @param AutoloaderInterface $autoloader * @param DirectoryList $dirList - * @param ComponentRegistrar $componentRegistrar * @return void */ - public static function populateMappings( - AutoloaderInterface $autoloader, - DirectoryList $dirList, - ComponentRegistrar $componentRegistrar - ) { + public static function populateMappings(AutoloaderInterface $autoloader, DirectoryList $dirList) + { + $modulesDir = $dirList->getPath(DirectoryList::ROOT) . '/app/code'; $generationDir = $dirList->getPath(DirectoryList::GENERATION); $frameworkDir = $dirList->getPath(DirectoryList::LIB_INTERNAL); - foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleName => $moduleDir) { - $autoloader->addPsr4(str_replace('_', '\\', $moduleName) . '\\', [$moduleDir . '/'], true); - } + $autoloader->addPsr4('Magento\\', [$modulesDir . '/Magento/', $generationDir . '/Magento/'], true); - $autoloader->addPsr4('Magento\\', [$generationDir . '/Magento/'], true); $autoloader->addPsr0('Apache_', $frameworkDir, true); $autoloader->addPsr0('Cm_', $frameworkDir, true); $autoloader->addPsr0('Credis_', $frameworkDir, true); diff --git a/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php b/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php index a75e61c14b069..23d043db7c6ff 100644 --- a/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php +++ b/lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php @@ -14,11 +14,6 @@ class PopulatorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\App\Filesystem\DirectoryList | \PHPUnit_Framework_MockObject_MockObject */ protected $mockDirectoryList; - /** - * @var \Magento\Framework\Component\ComponentRegistrar|\PHPUnit_Framework_MockObject_MockObject - */ - protected $componentRegistrar; - public function setUp() { $this->mockDirectoryList = $this->getMockBuilder('\Magento\Framework\App\Filesystem\DirectoryList') @@ -28,8 +23,6 @@ public function setUp() $this->mockDirectoryList->expects($this->any()) ->method('getPath') ->willReturnArgument(0); - - $this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); } public function testPopulateMappings() @@ -38,38 +31,32 @@ public function testPopulateMappings() ->disableOriginalConstructor() ->getMock(); - $mockAutoloader->expects($this->at(0))->method('addPsr4')->with('Magento\\A\\', ['/path/to/a/'], true); - $mockAutoloader->expects($this->at(1))->method('addPsr4')->with('Magento\\B\\', ['/path/to/b/'], true); - $mockAutoloader->expects($this->at(2))->method('addPsr4')->with('Magento\\C\\', ['/path/to/c/'], true); - $mockAutoloader->expects($this->at(3)) + $mockAutoloader->expects($this->at(0)) ->method('addPsr4') - ->with('Magento\\', [DirectoryList::GENERATION . '/Magento/'], true); - $mockAutoloader->expects($this->at(4)) + ->with( + 'Magento\\', + [DirectoryList::ROOT . '/app/code/Magento/', DirectoryList::GENERATION . '/Magento/'], + true + ); + $mockAutoloader->expects($this->at(1)) ->method('addPsr0') ->with('Apache_', DirectoryList::LIB_INTERNAL, true); - $mockAutoloader->expects($this->at(5)) + $mockAutoloader->expects($this->at(2)) ->method('addPsr0') ->with('Cm_', DirectoryList::LIB_INTERNAL, true); - $mockAutoloader->expects($this->at(6)) + $mockAutoloader->expects($this->at(3)) ->method('addPsr0') ->with('Credis_', DirectoryList::LIB_INTERNAL, true); - $mockAutoloader->expects($this->at(7)) + $mockAutoloader->expects($this->at(4)) ->method('addPsr0') ->with('Less_', DirectoryList::LIB_INTERNAL, true); - $mockAutoloader->expects($this->at(8)) + $mockAutoloader->expects($this->at(5)) ->method('addPsr0') ->with('Symfony\\', DirectoryList::LIB_INTERNAL, true); - $mockAutoloader->expects($this->at(9)) + $mockAutoloader->expects($this->at(6)) ->method('addPsr0') ->with('', [DirectoryList::GENERATION]); - $moduleDirs = [ - 'Magento_A' => '/path/to/a', - 'Magento_B' => '/path/to/b', - 'Magento_C' => '/path/to/c', - ]; - $this->componentRegistrar->expects($this->once())->method('getPaths')->willReturn($moduleDirs); - - Populator::populateMappings($mockAutoloader, $this->mockDirectoryList, $this->componentRegistrar); + Populator::populateMappings($mockAutoloader, $this->mockDirectoryList); } }