Skip to content

Commit ffea3cd

Browse files
committed
Merge pull request #591 from magento-ogre/PR_Branch
[Ogres] Bug Fixes
2 parents 0dfd558 + ab37a8e commit ffea3cd

File tree

33 files changed

+1085
-438
lines changed

33 files changed

+1085
-438
lines changed

app/code/Magento/Braintree/etc/di.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</type>
4040

4141
<!-- Logger, initialized with BraintreeConfig -->
42-
<virtualType name="BraintreeLogger" type="Magento\Payment\Model\Method\Logger">
42+
<virtualType name="BraintreeLoggerForTransactionSale" type="Magento\Payment\Model\Method\Logger">
4343
<arguments>
4444
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\Config</argument>
4545
</arguments>
@@ -164,22 +164,22 @@
164164

165165
<type name="Magento\Braintree\Gateway\Http\Client\TransactionSale">
166166
<arguments>
167-
<argument name="customLogger" xsi:type="object">BraintreeLogger</argument>
167+
<argument name="customLogger" xsi:type="object">BraintreeLoggerForTransactionSale</argument>
168168
</arguments>
169169
</type>
170170
<type name="Magento\Braintree\Gateway\Http\Client\TransactionSubmitForSettlement">
171171
<arguments>
172-
<argument name="customLogger" xsi:type="object">BraintreeLogger</argument>
172+
<argument name="customLogger" xsi:type="object">BraintreeLoggerForTransactionSale</argument>
173173
</arguments>
174174
</type>
175175
<type name="Magento\Braintree\Gateway\Http\Client\TransactionRefund">
176176
<arguments>
177-
<argument name="customLogger" xsi:type="object">BraintreeLogger</argument>
177+
<argument name="customLogger" xsi:type="object">BraintreeLoggerForTransactionSale</argument>
178178
</arguments>
179179
</type>
180180
<type name="Magento\Braintree\Gateway\Http\Client\TransactionVoid">
181181
<arguments>
182-
<argument name="customLogger" xsi:type="object">BraintreeLogger</argument>
182+
<argument name="customLogger" xsi:type="object">BraintreeLoggerForTransactionSale</argument>
183183
</arguments>
184184
</type>
185185

@@ -375,7 +375,7 @@
375375
</arguments>
376376
</virtualType>
377377

378-
<virtualType name="BraintreeTransactionsCollectionFactory" type="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
378+
<virtualType name="BraintreeTransactionsCollectionFactoryForReporting" type="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
379379
<arguments>
380380
<argument name="collections" xsi:type="array">
381381
<item name="braintree_report_data_source" xsi:type="string">Magento\Braintree\Model\Report\TransactionsCollection</item>
@@ -385,7 +385,7 @@
385385

386386
<virtualType name="BraintreeTransactionsReporting" type="Magento\Framework\View\Element\UiComponent\DataProvider\Reporting">
387387
<arguments>
388-
<argument name="collectionFactory" xsi:type="object">BraintreeTransactionsCollectionFactory</argument>
388+
<argument name="collectionFactory" xsi:type="object">BraintreeTransactionsCollectionFactoryForReporting</argument>
389389
</arguments>
390390
</virtualType>
391391

app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ protected function setUp()
299299
* Test for afterImportData()
300300
* Covers afterImportData() + protected methods used inside
301301
*
302-
* @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::afterImportData
303302
* @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::_populateForUrlGeneration
304303
* @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::isGlobalScope
305304
* @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::populateGlobalProduct

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@
2121
class ConfigurableTest extends \PHPUnit_Framework_TestCase
2222
{
2323
/**
24-
* @var VariationHandler|MockObject
24+
* @var Magento\ConfigurableProduct\Model\Product\VariationHandler|MockObject
2525
*/
2626
private $variationHandler;
2727

2828
/**
29-
* @var Http|MockObject
29+
* @var Magento\Framework\App\Request\Http|MockObject
3030
*/
3131
private $request;
3232

3333
/**
34-
* @var Factory|MockObject
34+
* @var Magento\ConfigurableProduct\Helper\Product\Options\Factory|MockObject
3535
*/
3636
private $optionFactory;
3737

3838
/**
39-
* @var Product|MockObject
39+
* @var Magento\Catalog\Model\Product|MockObject
4040
*/
4141
private $product;
4242

4343
/**
44-
* @var Helper|MockObject
44+
* @var Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper|MockObject
4545
*/
4646
private $subject;
4747

@@ -203,9 +203,6 @@ public function testAfterInitializeWithAttributesAndVariations()
203203
$this->plugin->afterInitialize($this->subject, $this->product);
204204
}
205205

206-
/**
207-
* @covers Configurable::afterInitialize
208-
*/
209206
public function testAfterInitializeWithAttributesAndWithoutVariations()
210207
{
211208
$attributes = [
@@ -268,9 +265,6 @@ public function testAfterInitializeWithAttributesAndWithoutVariations()
268265
$this->plugin->afterInitialize($this->subject, $this->product);
269266
}
270267

271-
/**
272-
* @covers Configurable::afterInitialize
273-
*/
274268
public function testAfterInitializeIfAttributesEmpty()
275269
{
276270
$this->product->expects(static::once())
@@ -291,9 +285,6 @@ public function testAfterInitializeIfAttributesEmpty()
291285
$this->plugin->afterInitialize($this->subject, $this->product);
292286
}
293287

294-
/**
295-
* @covers Configurable::afterInitialize
296-
*/
297288
public function testAfterInitializeForNotConfigurableProduct()
298289
{
299290
$this->product->expects(static::once())

app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function setUp()
1919
}
2020

2121
/**
22-
* @covers \Magento\Marketplace\Helper::loadPartnersFromCache
22+
* @covers \Magento\Marketplace\Helper\Cache::loadPartnersFromCache
2323
*/
2424
public function testLoadPartnersFromCache()
2525
{
@@ -36,7 +36,7 @@ public function testLoadPartnersFromCache()
3636
}
3737

3838
/**
39-
* @covers \Magento\Marketplace\Helper::savePartnersToCache
39+
* @covers \Magento\Marketplace\Helper\Cache::savePartnersToCache
4040
*/
4141
public function testSavePartnersToCache()
4242
{

dev/tests/functional/tests/app/Magento/Backend/Test/Fixture/Source/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Class Date.
1313
*
1414
* Data keys:
15-
* - pattern (Format a local time/date with delta, e.g. 'm-d-Y -3 days' = current day - 3 days)
15+
* - pattern (Format a local time/date with delta, e.g. 'm/d/Y -3 days' = current day - 3 days)
1616
*/
1717
class Date extends DataSource
1818
{

dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,13 @@ public function testCoversAnnotation()
598598
{
599599
$files = Files::init();
600600
$errors = [];
601-
foreach ($files->getFiles([BP . '/dev/tests/{integration,unit}'], '*') as $file) {
601+
$filesToTest = $files->getPhpFiles(Files::INCLUDE_TESTS);
602+
603+
if (($key = array_search(__FILE__, $filesToTest)) !== false) {
604+
unset($filesToTest[$key]);
605+
}
606+
607+
foreach ($filesToTest as $file) {
602608
$code = file_get_contents($file);
603609
if (preg_match('/@covers(DefaultClass)?\s+([\w\\\\]+)(::([\w\\\\]+))?/', $code, $matches)) {
604610
if ($this->isNonexistentEntityCovered($matches)) {

lib/internal/Magento/Framework/App/ObjectManagerFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\ObjectManager\Definition\Compiled\Serialized;
1414
use Magento\Framework\App\ObjectManager\Environment;
1515
use Magento\Framework\Config\File\ConfigFilePool;
16+
use Magento\Framework\Code\GeneratedFiles;
1617

1718
/**
1819
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -108,6 +109,10 @@ public function __construct(DirectoryList $directoryList, DriverPool $driverPool
108109
*/
109110
public function create(array $arguments)
110111
{
112+
$writeFactory = new \Magento\Framework\Filesystem\Directory\WriteFactory($this->driverPool);
113+
$generatedFiles = new GeneratedFiles($this->directoryList, $writeFactory);
114+
$generatedFiles->regenerate();
115+
111116
$deploymentConfig = $this->createDeploymentConfig($this->directoryList, $this->configFilePool, $arguments);
112117
$arguments = array_merge($deploymentConfig->get(), $arguments);
113118
$definitionFactory = new \Magento\Framework\ObjectManager\DefinitionFactory(
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Code;
7+
8+
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Filesystem\Directory\WriteFactory;
10+
use Magento\Framework\Filesystem\Directory\WriteInterface;
11+
12+
/**
13+
* Regenerates generated code and DI configuration
14+
*/
15+
class GeneratedFiles
16+
{
17+
/**
18+
* Separator literal to assemble timer identifier from timer names
19+
*/
20+
const REGENERATE_FLAG = '/var/.regenerate';
21+
22+
/**
23+
* @var DirectoryList
24+
*/
25+
private $directoryList;
26+
27+
/**
28+
* @var WriteInterface
29+
*/
30+
private $write;
31+
32+
/**
33+
* Constructor
34+
*
35+
* @param DirectoryList $directoryList
36+
* @param WriteFactory $writeFactory
37+
*/
38+
public function __construct(DirectoryList $directoryList, WriteFactory $writeFactory)
39+
{
40+
$this->directoryList = $directoryList;
41+
$this->write = $writeFactory->create(BP);
42+
}
43+
44+
/**
45+
* Clean generated code and DI configuration
46+
*
47+
* @return void
48+
*/
49+
public function regenerate()
50+
{
51+
if ($this->write->isExist(self::REGENERATE_FLAG)) {
52+
$generationPath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::GENERATION));
53+
$diPath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::DI));
54+
55+
if ($this->write->isDirectory($generationPath)) {
56+
$this->write->delete($generationPath);
57+
}
58+
if ($this->write->isDirectory($diPath)) {
59+
$this->write->delete($diPath);
60+
}
61+
$this->write->delete(self::REGENERATE_FLAG);
62+
}
63+
}
64+
65+
/**
66+
* Create flag for regeneration of code and di
67+
*
68+
* @return void
69+
*/
70+
public function requestRegeneration()
71+
{
72+
$this->write->touch(self::REGENERATE_FLAG);
73+
}
74+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Code\Test\Unit;
8+
9+
use Magento\Framework\App\Filesystem\DirectoryList;
10+
use Magento\Framework\Code\GeneratedFiles;
11+
12+
class GeneratedFilesTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/**
15+
* @var Magento\Framework\App\Filesystem\DirectoryList | \PHPUnit_Framework_MockObject_MockObject
16+
*/
17+
private $directoryList;
18+
19+
/**
20+
* @var Magento\Framework\Filesystem\Directory\WriteInterface | \PHPUnit_Framework_MockObject_MockObject
21+
*/
22+
private $writeInterface;
23+
24+
/**
25+
* @var \Magento\Framework\Code\GeneratedFiles
26+
*/
27+
private $model;
28+
29+
protected function setUp()
30+
{
31+
$this->directoryList = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
32+
$writeFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false);
33+
$this->writeInterface = $this->getMock(
34+
'\Magento\Framework\Filesystem\Directory\WriteInterface',
35+
[],
36+
[],
37+
'',
38+
false
39+
);
40+
$writeFactory->expects($this->once())->method('create')->willReturn($this->writeInterface);
41+
$this->model = new GeneratedFiles($this->directoryList, $writeFactory);
42+
}
43+
44+
/**
45+
* @param array $getPathMap
46+
* @param array $isDirectoryMap
47+
* @param array $deleteMap
48+
* @dataProvider regenerateDataProvider
49+
*/
50+
public function testRegenerate($getPathMap, $isDirectoryMap, $deleteMap)
51+
{
52+
53+
$this->writeInterface
54+
->expects($this->once())
55+
->method('isExist')
56+
->with(GeneratedFiles::REGENERATE_FLAG)
57+
->willReturn(true);
58+
$this->directoryList->expects($this->exactly(2))->method('getPath')->willReturnMap($getPathMap);
59+
$this->writeInterface->expects($this->exactly(2))->method('getRelativePath')->willReturnMap($getPathMap);
60+
$this->writeInterface->expects($this->exactly(2))->method('isDirectory')->willReturnMap($isDirectoryMap);
61+
$this->writeInterface->expects($this->exactly(1))->method('delete')->willReturnMap($deleteMap);
62+
$this->model->regenerate();
63+
}
64+
65+
/**
66+
* @return array
67+
*/
68+
public function regenerateDataProvider()
69+
{
70+
$pathToGeneration = 'path/to/generation';
71+
$pathToDi = 'path/to/di';
72+
73+
$getPathMap = [[DirectoryList::GENERATION, $pathToGeneration],
74+
[DirectoryList::DI, $pathToDi]];
75+
$deleteMap = [[BP . '/' . $pathToGeneration, true],
76+
[BP . '/' . $pathToDi, true],
77+
[BP . GeneratedFiles::REGENERATE_FLAG, true],
78+
];
79+
80+
return [
81+
'runAll' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true],
82+
[BP . '/' . $pathToDi, true]], $deleteMap ],
83+
'noDIfolder' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true],
84+
[BP . '/' . $pathToDi, false]], $deleteMap],
85+
'noGenerationfolder' => [$getPathMap, [[BP . '/' . $pathToGeneration, false],
86+
[BP . '/' . $pathToDi, true]], $deleteMap],
87+
'nofolders' => [ $getPathMap, [[BP . '/' . $pathToGeneration, false],
88+
[BP . '/' . $pathToDi, false]], $deleteMap],
89+
];
90+
}
91+
92+
public function testRegenerateWithNoFlag()
93+
{
94+
$this->writeInterface
95+
->expects($this->once())
96+
->method('isExist')
97+
->with(GeneratedFiles::REGENERATE_FLAG)
98+
->willReturn(false);
99+
$this->directoryList->expects($this->never())->method('getPath');
100+
$this->writeInterface->expects($this->never())->method('getPath');
101+
$this->writeInterface->expects($this->never())->method('delete');
102+
$this->model->regenerate();
103+
}
104+
105+
public function testRequestRegeneration()
106+
{
107+
$this->writeInterface->expects($this->once())->method("touch");
108+
$this->model->requestRegeneration();
109+
}
110+
}

0 commit comments

Comments
 (0)