Skip to content

Commit 39abd59

Browse files
committed
MAGETWO-42265: Fix code that depends on module location
- fixing integration tests - fixing integrity test - fixing code style
1 parent b08b20a commit 39abd59

File tree

7 files changed

+34
-60
lines changed

7 files changed

+34
-60
lines changed

app/code/Magento/Paypal/Block/Payflow/Advanced/Iframe.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ class Iframe extends \Magento\Paypal\Block\Payflow\Link\Iframe
1717
* @param \Magento\Sales\Model\OrderFactory $orderFactory
1818
* @param \Magento\Checkout\Model\Session $checkoutSession
1919
* @param \Magento\Paypal\Helper\Hss $hssHelper
20-
* @param \Magento\Payment\Helper\Data $paymentData
2120
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
2221
* @param \Magento\Framework\Module\Dir\Reader $reader
22+
* @param \Magento\Payment\Helper\Data $paymentData
2323
* @param array $data
2424
*/
2525
public function __construct(
2626
\Magento\Framework\View\Element\Template\Context $context,
2727
\Magento\Sales\Model\OrderFactory $orderFactory,
2828
\Magento\Checkout\Model\Session $checkoutSession,
2929
\Magento\Paypal\Helper\Hss $hssHelper,
30-
\Magento\Payment\Helper\Data $paymentData,
3130
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
3231
\Magento\Framework\Module\Dir\Reader $reader,
32+
\Magento\Payment\Helper\Data $paymentData,
3333
array $data = []
3434
) {
3535
parent::__construct(
3636
$context,
3737
$orderFactory,
3838
$checkoutSession,
3939
$hssHelper,
40-
$paymentData,
4140
$readFactory,
4241
$reader,
42+
$paymentData,
4343
$data
4444
);
4545
$this->_isScopePrivate = false;

app/code/Magento/Paypal/Block/Payflow/Link/Iframe.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ class Iframe extends \Magento\Paypal\Block\Iframe
2222
* @param \Magento\Sales\Model\OrderFactory $orderFactory
2323
* @param \Magento\Checkout\Model\Session $checkoutSession
2424
* @param \Magento\Paypal\Helper\Hss $hssHelper
25-
* @param \Magento\Payment\Helper\Data $paymentData
2625
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
2726
* @param \Magento\Framework\Module\Dir\Reader $reader
27+
* @param \Magento\Payment\Helper\Data $paymentData
2828
* @param array $data
2929
*/
3030
public function __construct(
3131
\Magento\Framework\View\Element\Template\Context $context,
3232
\Magento\Sales\Model\OrderFactory $orderFactory,
3333
\Magento\Checkout\Model\Session $checkoutSession,
3434
\Magento\Paypal\Helper\Hss $hssHelper,
35-
\Magento\Payment\Helper\Data $paymentData,
3635
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
3736
\Magento\Framework\Module\Dir\Reader $reader,
37+
\Magento\Payment\Helper\Data $paymentData,
3838
array $data = []
3939
) {
4040
$this->_paymentData = $paymentData;

app/code/Magento/Paypal/Test/Unit/Block/Payflow/Link/IframeTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public function testCheckIsScopePrivate()
9090
$this->orderFactoryMock,
9191
$this->checkoutSessionMock,
9292
$this->hssHelperMock,
93-
$this->paymentDataMock,
9493
$this->readFactory,
95-
$this->reader
94+
$this->reader,
95+
$this->paymentDataMock
9696
);
9797

9898
$this->assertFalse($block->isScopePrivate());
@@ -120,9 +120,9 @@ public function testGetTransactionUrlLive()
120120
$this->orderFactoryMock,
121121
$this->checkoutSessionMock,
122122
$this->hssHelperMock,
123-
$this->paymentDataMock,
124123
$this->readFactory,
125-
$this->reader
124+
$this->reader,
125+
$this->paymentDataMock
126126
);
127127
$this->assertEquals($expected, $block->getTransactionUrl());
128128
}
@@ -149,9 +149,9 @@ public function testGetTransactionUrlTest()
149149
$this->orderFactoryMock,
150150
$this->checkoutSessionMock,
151151
$this->hssHelperMock,
152-
$this->paymentDataMock,
153152
$this->readFactory,
154-
$this->reader
153+
$this->reader,
154+
$this->paymentDataMock
155155
);
156156
$this->assertEquals($expected, $block->getTransactionUrl());
157157
}

dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/FileResolverStub.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@ class FileResolverStub implements \Magento\Framework\Config\FileResolverInterfac
1414
*/
1515
public function get($filename, $scope)
1616
{
17-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
18-
$readDirectory = $objectManager->create(
19-
'Magento\Framework\Filesystem\Directory\Read',
20-
[
21-
'driver' => $objectManager->create('Magento\Framework\Filesystem\Driver\File'),
22-
'path' => realpath(__DIR__ . '/../../_files/etc'),
23-
]
24-
);
25-
$paths = ['search_request_1.xml', 'search_request_2.xml'];
26-
return new \Magento\Framework\Config\FileIterator($readDirectory, $paths);
17+
$path = realpath(__DIR__ . '/../../_files/etc');
18+
$paths = [$path . '/search_request_1.xml', $path . '/search_request_2.xml'];
19+
return new \Magento\Framework\Config\FileIterator(new \Magento\Framework\Filesystem\Driver\File, $paths);
2720
}
2821
}

lib/internal/Magento/Framework/App/Utility/Files.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ public function classFileExists($class, &$path = '')
11461146
$fullPath = $dir . $path;
11471147
$trimmedFullPath = $dir . explode('/', $path, 3)[2];
11481148
if ($this->classFileExistsCheckContent($fullPath, $namespace, $className)
1149-
|| $this->classFileExistsCheckContent($trimmedFullPath, $namespace, $class)
1149+
|| $this->classFileExistsCheckContent($trimmedFullPath, $namespace, $className)
11501150
) {
11511151
return true;
11521152
}
@@ -1159,7 +1159,7 @@ public function classFileExists($class, &$path = '')
11591159
*
11601160
* @param string $fullPath
11611161
* @param string $namespace
1162-
* @param $className
1162+
* @param string $className
11631163
* @return bool
11641164
*/
11651165
private function classFileExistsCheckContent($fullPath, $namespace, $className)

lib/internal/Magento/Framework/Autoload/Populator.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Framework\Autoload;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9-
use Magento\Framework\Component\ComponentRegistrar;
9+
use Magento\Framework\Autoload\AutoloaderInterface;
1010
use Magento\Framework\Filesystem\FileResolver;
1111

1212
/**
@@ -18,22 +18,16 @@ class Populator
1818
/**
1919
* @param AutoloaderInterface $autoloader
2020
* @param DirectoryList $dirList
21-
* @param ComponentRegistrar $componentRegistrar
2221
* @return void
2322
*/
24-
public static function populateMappings(
25-
AutoloaderInterface $autoloader,
26-
DirectoryList $dirList,
27-
ComponentRegistrar $componentRegistrar
28-
) {
23+
public static function populateMappings(AutoloaderInterface $autoloader, DirectoryList $dirList)
24+
{
25+
$modulesDir = $dirList->getPath(DirectoryList::ROOT) . '/app/code';
2926
$generationDir = $dirList->getPath(DirectoryList::GENERATION);
3027
$frameworkDir = $dirList->getPath(DirectoryList::LIB_INTERNAL);
3128

32-
foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleName => $moduleDir) {
33-
$autoloader->addPsr4(str_replace('_', '\\', $moduleName) . '\\', [$moduleDir . '/'], true);
34-
}
29+
$autoloader->addPsr4('Magento\\', [$modulesDir . '/Magento/', $generationDir . '/Magento/'], true);
3530

36-
$autoloader->addPsr4('Magento\\', [$generationDir . '/Magento/'], true);
3731
$autoloader->addPsr0('Apache_', $frameworkDir, true);
3832
$autoloader->addPsr0('Cm_', $frameworkDir, true);
3933
$autoloader->addPsr0('Credis_', $frameworkDir, true);

lib/internal/Magento/Framework/Autoload/Test/Unit/PopulatorTest.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ class PopulatorTest extends \PHPUnit_Framework_TestCase
1414
/** @var \Magento\Framework\App\Filesystem\DirectoryList | \PHPUnit_Framework_MockObject_MockObject */
1515
protected $mockDirectoryList;
1616

17-
/**
18-
* @var \Magento\Framework\Component\ComponentRegistrar|\PHPUnit_Framework_MockObject_MockObject
19-
*/
20-
protected $componentRegistrar;
21-
2217
public function setUp()
2318
{
2419
$this->mockDirectoryList = $this->getMockBuilder('\Magento\Framework\App\Filesystem\DirectoryList')
@@ -28,8 +23,6 @@ public function setUp()
2823
$this->mockDirectoryList->expects($this->any())
2924
->method('getPath')
3025
->willReturnArgument(0);
31-
32-
$this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false);
3326
}
3427

3528
public function testPopulateMappings()
@@ -38,38 +31,32 @@ public function testPopulateMappings()
3831
->disableOriginalConstructor()
3932
->getMock();
4033

41-
$mockAutoloader->expects($this->at(0))->method('addPsr4')->with('Magento\\A\\', ['/path/to/a/'], true);
42-
$mockAutoloader->expects($this->at(1))->method('addPsr4')->with('Magento\\B\\', ['/path/to/b/'], true);
43-
$mockAutoloader->expects($this->at(2))->method('addPsr4')->with('Magento\\C\\', ['/path/to/c/'], true);
44-
$mockAutoloader->expects($this->at(3))
34+
$mockAutoloader->expects($this->at(0))
4535
->method('addPsr4')
46-
->with('Magento\\', [DirectoryList::GENERATION . '/Magento/'], true);
47-
$mockAutoloader->expects($this->at(4))
36+
->with(
37+
'Magento\\',
38+
[DirectoryList::ROOT . '/app/code/Magento/', DirectoryList::GENERATION . '/Magento/'],
39+
true
40+
);
41+
$mockAutoloader->expects($this->at(1))
4842
->method('addPsr0')
4943
->with('Apache_', DirectoryList::LIB_INTERNAL, true);
50-
$mockAutoloader->expects($this->at(5))
44+
$mockAutoloader->expects($this->at(2))
5145
->method('addPsr0')
5246
->with('Cm_', DirectoryList::LIB_INTERNAL, true);
53-
$mockAutoloader->expects($this->at(6))
47+
$mockAutoloader->expects($this->at(3))
5448
->method('addPsr0')
5549
->with('Credis_', DirectoryList::LIB_INTERNAL, true);
56-
$mockAutoloader->expects($this->at(7))
50+
$mockAutoloader->expects($this->at(4))
5751
->method('addPsr0')
5852
->with('Less_', DirectoryList::LIB_INTERNAL, true);
59-
$mockAutoloader->expects($this->at(8))
53+
$mockAutoloader->expects($this->at(5))
6054
->method('addPsr0')
6155
->with('Symfony\\', DirectoryList::LIB_INTERNAL, true);
62-
$mockAutoloader->expects($this->at(9))
56+
$mockAutoloader->expects($this->at(6))
6357
->method('addPsr0')
6458
->with('', [DirectoryList::GENERATION]);
6559

66-
$moduleDirs = [
67-
'Magento_A' => '/path/to/a',
68-
'Magento_B' => '/path/to/b',
69-
'Magento_C' => '/path/to/c',
70-
];
71-
$this->componentRegistrar->expects($this->once())->method('getPaths')->willReturn($moduleDirs);
72-
73-
Populator::populateMappings($mockAutoloader, $this->mockDirectoryList, $this->componentRegistrar);
60+
Populator::populateMappings($mockAutoloader, $this->mockDirectoryList);
7461
}
7562
}

0 commit comments

Comments
 (0)