Skip to content

Commit 1f7a63d

Browse files
committed
Merge pull request #504 from magento-ogre/PR_Branch
[Ogres] Bug fixes
2 parents d447fa6 + b2c8564 commit 1f7a63d

File tree

15 files changed

+314
-56
lines changed

15 files changed

+314
-56
lines changed

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getDataSet(
7373
array $dimensions,
7474
Table $entityIdsTable
7575
) {
76-
$currentScope = $dimensions['scope']->getValue();
76+
$currentScope = $this->scopeResolver->getScope($dimensions['scope']->getValue())->getId();
7777

7878
$attribute = $this->eavConfig->getAttribute(Product::ENTITY, $bucket->getField());
7979

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public function aroundGetDataSet(
6767
Table $entityIdsTable
6868
) {
6969
if ($bucket->getField() == 'category_ids') {
70-
$currentScope = $dimensions['scope']->getValue();
71-
$currentScopeId = $this->scopeResolver->getScope($currentScope)->getId();
70+
$currentScopeId = $this->scopeResolver->getScope($dimensions['scope']->getValue())->getId();
7271
$currentCategory = $this->layer->getCurrentCategory();
7372

7473
$derivedTable = $this->resource->getConnection()->select();

app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver;
2121
use Magento\Store\Model\ScopeInterface;
2222
use Magento\Store\Model\StoreManagerInterface;
23+
use Magento\Framework\App\ScopeResolverInterface;
2324

2425
/**
2526
* Build base Query for Index
@@ -57,28 +58,36 @@ class IndexBuilder implements IndexBuilderInterface
5758
*/
5859
private $tableMapper;
5960

61+
/**
62+
* @var ScopeResolverInterface
63+
*/
64+
private $dimensionScopeResolver;
65+
6066
/**
6167
* @param \Magento\Framework\App\ResourceConnection $resource
6268
* @param ScopeConfigInterface $config
6369
* @param StoreManagerInterface $storeManager
6470
* @param ConditionManager $conditionManager
6571
* @param IndexScopeResolver $scopeResolver
6672
* @param TableMapper $tableMapper
73+
* @param ScopeResolverInterface $dimensionScopeResolver
6774
*/
6875
public function __construct(
6976
ResourceConnection $resource,
7077
ScopeConfigInterface $config,
7178
StoreManagerInterface $storeManager,
7279
ConditionManager $conditionManager,
7380
IndexScopeResolver $scopeResolver,
74-
TableMapper $tableMapper
81+
TableMapper $tableMapper,
82+
ScopeResolverInterface $dimensionScopeResolver
7583
) {
7684
$this->resource = $resource;
7785
$this->config = $config;
7886
$this->storeManager = $storeManager;
7987
$this->conditionManager = $conditionManager;
8088
$this->scopeResolver = $scopeResolver;
8189
$this->tableMapper = $tableMapper;
90+
$this->dimensionScopeResolver = $dimensionScopeResolver;
8291
}
8392

8493
/**
@@ -158,7 +167,7 @@ private function prepareDimensions(array $dimensions)
158167
$preparedDimensions[] = $this->conditionManager->generateCondition(
159168
$dimension->getName(),
160169
'=',
161-
$dimension->getValue()
170+
$this->dimensionScopeResolver->getScope($dimension->getValue())->getId()
162171
);
163172
}
164173

app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,55 @@
66

77
namespace Magento\CatalogSearch\Test\Unit\Model\Search;
88

9-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
10-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
11-
129
/**
1310
* Test for \Magento\CatalogSearch\Model\Search\IndexBuilder
11+
*
12+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1413
*/
1514
class IndexBuilderTest extends \PHPUnit_Framework_TestCase
1615
{
17-
/** @var \Magento\CatalogSearch\Model\Search\TableMapper|MockObject */
16+
/** @var \Magento\CatalogSearch\Model\Search\TableMapper|\PHPUnit_Framework_MockObject_MockObject */
1817
private $tableMapper;
1918

20-
/** @var \Magento\Framework\Search\Adapter\Mysql\ConditionManager|MockObject */
19+
/** @var \Magento\Framework\Search\Adapter\Mysql\ConditionManager|\PHPUnit_Framework_MockObject_MockObject */
2120
private $conditionManager;
2221

23-
/** @var \Magento\Search\Model\IndexScopeResolver|MockObject */
22+
/** @var \Magento\Search\Model\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject */
2423
private $scopeResolver;
2524

26-
/** @var \Magento\Framework\DB\Adapter\AdapterInterface|MockObject */
25+
/** @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */
2726
private $connection;
2827

29-
/** @var \Magento\Framework\DB\Select|MockObject */
28+
/** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject */
3029
private $select;
3130

32-
/** @var \Magento\Framework\App\Config\ScopeConfigInterface|MockObject */
31+
/** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
3332
private $config;
3433

35-
/** @var \Magento\Store\Model\StoreManagerInterface|MockObject */
34+
/** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
3635
private $storeManager;
3736

38-
/** @var \Magento\Framework\Search\RequestInterface|MockObject */
37+
/** @var \Magento\Framework\Search\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
3938
private $request;
4039

41-
/** @var \Magento\Search\Model\IndexScopeResolver|MockObject */
40+
/** @var \Magento\Search\Model\IndexScopeResolver|\PHPUnit_Framework_MockObject_MockObject */
4241
private $resource;
4342

4443
/**
4544
* @var \Magento\CatalogSearch\Model\Search\IndexBuilder
4645
*/
4746
private $target;
4847

48+
/**
49+
* @var \Magento\Framework\App\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject
50+
*/
51+
private $dimensionScopeResolver;
52+
53+
/**
54+
* @var \Magento\Framework\App\ScopeInterface|\PHPUnit_Framework_MockObject_MockObject
55+
*/
56+
private $scopeInterface;
57+
4958
protected function setUp()
5059
{
5160
$this->select = $this->getMockBuilder('\Magento\Framework\DB\Select')
@@ -118,8 +127,20 @@ function ($left, $operator, $right) {
118127
->method('addTables')
119128
->with($this->select, $this->request)
120129
->willReturnArgument(0);
130+
$this->dimensionScopeResolver = $this->getMockForAbstractClass(
131+
'\Magento\Framework\App\ScopeResolverInterface',
132+
[],
133+
'',
134+
false
135+
);
136+
$this->scopeInterface = $this->getMockForAbstractClass(
137+
'\Magento\Framework\App\ScopeInterface',
138+
[],
139+
'',
140+
false
141+
);
121142

122-
$objectManagerHelper = new ObjectManagerHelper($this);
143+
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
123144
$this->target = $objectManagerHelper->getObject(
124145
'Magento\CatalogSearch\Model\Search\IndexBuilder',
125146
[
@@ -129,6 +150,7 @@ function ($left, $operator, $right) {
129150
'conditionManager' => $this->conditionManager,
130151
'scopeResolver' => $this->scopeResolver,
131152
'tableMapper' => $this->tableMapper,
153+
'dimensionScopeResolver' => $this->dimensionScopeResolver
132154
]
133155
);
134156
}
@@ -167,6 +189,12 @@ public function testBuildWithoutOutOfStock()
167189
$this->request->expects($this->exactly(2))
168190
->method('getDimensions')
169191
->willReturn($dimensions);
192+
$this->dimensionScopeResolver->expects($this->once())
193+
->method('getScope')
194+
->willReturn($this->scopeInterface);
195+
$this->scopeInterface->expects($this->once())
196+
->method('getId')
197+
->willReturn('someValue');
170198

171199
$this->mockBuild($index, $tableSuffix, false);
172200

@@ -270,7 +298,7 @@ function ($index, $dimensions) {
270298
/**
271299
* @param $name
272300
* @param $value
273-
* @return MockObject
301+
* @return \PHPUnit_Framework_MockObject_MockObject
274302
*/
275303
private function createDimension($name, $value)
276304
{

app/code/Magento/CatalogUrlRewrite/etc/setup/events.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/code/Magento/CmsUrlRewrite/etc/setup/events.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Filesystem\Filter;
8+
9+
/**
10+
* Filters Iterator to exclude specified files
11+
*/
12+
class ExcludeFilter extends \FilterIterator
13+
{
14+
/**
15+
* Array that is used for filtering
16+
*
17+
* @var array
18+
*/
19+
protected $_filters;
20+
21+
/**
22+
* Constructor
23+
*
24+
* @param \Iterator $iterator
25+
* @param array $filters list of files to skip
26+
*/
27+
public function __construct(\Iterator $iterator, array $filters)
28+
{
29+
parent::__construct($iterator);
30+
$this->_filters = $filters;
31+
}
32+
33+
/**
34+
* Check whether the current element of the iterator is acceptable
35+
*
36+
* @return bool
37+
*/
38+
public function accept()
39+
{
40+
$current = str_replace('\\', '/', $this->current()->__toString());
41+
$currentFilename = str_replace('\\', '/', $this->current()->getFilename());
42+
43+
if ($currentFilename == '.' || $currentFilename == '..') {
44+
return false;
45+
}
46+
47+
foreach ($this->_filters as $filter) {
48+
$filter = str_replace('\\', '/', $filter);
49+
if (false !== strpos($current, $filter)) {
50+
return false;
51+
}
52+
}
53+
54+
return true;
55+
}
56+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Filesystem\Test\Unit\File;
8+
9+
use \Magento\Framework\Filesystem\Filter\ExcludeFilter;
10+
11+
/**
12+
* Class ExcludeFilterTest
13+
*/
14+
class ExcludeFilterTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @var \Iterator
18+
*/
19+
protected $iterator;
20+
21+
protected function setUp()
22+
{
23+
$this->iterator = $this->getFilesIterator();
24+
}
25+
26+
public function testExclusion()
27+
{
28+
$iterator = new ExcludeFilter(
29+
$this->iterator,
30+
[
31+
BP . '/var/session/'
32+
]
33+
);
34+
35+
foreach ($iterator as $i) {
36+
$result[] = $i;
37+
}
38+
39+
$this->assertTrue(!in_array(BP . '/var/session/', $result), 'Filtered path should not be in array');
40+
}
41+
42+
private function getFilesIterator ()
43+
{
44+
$files = [
45+
BP . '/var/',
46+
BP . '/var/session/',
47+
BP . '/var/cache/'
48+
];
49+
50+
foreach ($files as $file) {
51+
$item = $this->getMockBuilder('SplFileInfoClass')->setMethods(['__toString', 'getFilename'])->getMock();
52+
$item->expects($this->any())->method('__toString')->willReturn($file);
53+
$item->expects($this->any())->method('getFilename')->willReturn('notDots');
54+
yield $item;
55+
}
56+
}
57+
}

lib/internal/Magento/Framework/Module/DependencyChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function __construct(ModuleList $list, ModuleList\Loader $loader, Package
5050
$this->enabledModuleList = $list->getNames();
5151
$this->fullModuleList = $loader->load();
5252
$this->packageInfo = $packageInfoFactory->create();
53-
$this->graph = $this->createGraph();
5453
}
5554

5655
/**
@@ -93,6 +92,7 @@ public function checkDependenciesWhenEnableModules($toBeEnabledModules, $current
9392
*/
9493
private function checkDependencyGraph($isEnable, $moduleNames, $enabledModules)
9594
{
95+
$this->graph = $this->createGraph();
9696
$dependenciesMissingAll = [];
9797
$graphMode = $isEnable ? Graph::DIRECTIONAL : Graph::INVERSE;
9898
foreach ($moduleNames as $moduleName) {

lib/internal/Magento/Framework/Search/Search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function search(SearchCriteriaInterface $searchCriteria)
5757
{
5858
$this->requestBuilder->setRequestName($searchCriteria->getRequestName());
5959

60-
$scope = $this->scopeResolver->getScope();
60+
$scope = $this->scopeResolver->getScope()->getId();
6161
$this->requestBuilder->bindDimension('scope', $scope);
6262

6363
foreach ($searchCriteria->getFilterGroups() as $filterGroup) {

lib/internal/Magento/Framework/Search/Test/Unit/SearchTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ protected function setUp()
6565
public function testSearch()
6666
{
6767
$requestName = 'requestName';
68-
$scope = 333;
68+
$scopeId = 333;
6969
$filterField = 'filterField';
7070
$filterValue = 'filterValue';
7171

72+
$scope = $this->getMockBuilder('Magento\Framework\App\ScopeInterface')
73+
->disableOriginalConstructor()
74+
->getMockForAbstractClass();
75+
7276
$filter = $this->getMockBuilder('Magento\Framework\Api\Filter')
7377
->disableOriginalConstructor()
7478
->getMock();
@@ -113,7 +117,7 @@ public function testSearch()
113117
->with($requestName);
114118
$this->requestBuilder->expects($this->once())
115119
->method('bindDimension')
116-
->with('scope', $scope);
120+
->with('scope', $scopeId);
117121
$this->requestBuilder->expects($this->any())
118122
->method('bind');
119123
$this->requestBuilder->expects($this->once())
@@ -134,6 +138,10 @@ public function testSearch()
134138
->method('getScope')
135139
->willReturn($scope);
136140

141+
$scope->expects($this->once())
142+
->method('getId')
143+
->willReturn($scopeId);
144+
137145
$searchResult = $this->model->search($searchCriteria);
138146

139147
$this->assertInstanceOf('Magento\Framework\Api\Search\SearchResultInterface', $searchResult);

0 commit comments

Comments
 (0)