Skip to content

Commit 96b12f1

Browse files
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into MAGETWO-37552
2 parents e88b84d + 2bcd7f3 commit 96b12f1

File tree

4 files changed

+160
-15
lines changed

4 files changed

+160
-15
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Search\Model;
7+
8+
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
10+
class EngineResolver
11+
{
12+
/**
13+
* MySQL search engine
14+
*/
15+
const CATALOG_SEARCH_MYSQL_ENGINE = 'mysql';
16+
17+
/**
18+
* @var ScopeConfigInterface
19+
*/
20+
protected $scopeConfig;
21+
22+
/**
23+
* Path to catalog search engine
24+
* @var string
25+
*/
26+
protected $path;
27+
28+
/**
29+
* Scope type
30+
* @var string
31+
*/
32+
protected $scopeType;
33+
34+
/**
35+
* Scope code
36+
* @var null|string
37+
*/
38+
protected $scopeCode;
39+
40+
/**
41+
* @param ScopeConfigInterface $scopeConfig
42+
* @param string $path
43+
* @param string $scopeType
44+
* @param string $scopeCode
45+
*/
46+
public function __construct(
47+
ScopeConfigInterface $scopeConfig,
48+
$path,
49+
$scopeType,
50+
$scopeCode = null
51+
) {
52+
$this->scopeConfig = $scopeConfig;
53+
$this->path = $path;
54+
$this->scopeType = $scopeType;
55+
$this->scopeCode = $scopeCode;
56+
}
57+
58+
/**
59+
* Current Search Engine
60+
* @return string
61+
*/
62+
public function getCurrentSearchEngine()
63+
{
64+
return $this->scopeConfig->getValue(
65+
$this->path,
66+
$this->scopeType,
67+
$this->scopeCode
68+
);
69+
}
70+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Search\Test\Unit\Model;
7+
8+
use Magento\Search\Model\EngineResolver;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
11+
class EngineResolverTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Search\Model\EngineResolver
15+
*/
16+
private $model;
17+
18+
/**
19+
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
protected $scopeConfig;
22+
23+
/**
24+
* @var string|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
protected $path;
27+
28+
/**
29+
* @var string|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
protected $scopeType;
32+
33+
/**
34+
* @var null|string|\PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
protected $scopeCode;
37+
38+
/**
39+
* Setup
40+
*
41+
* @return void
42+
*/
43+
protected function setUp()
44+
{
45+
$this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')
46+
->disableOriginalConstructor()
47+
->getMock();
48+
49+
$this->path = 'catalog/search/engine';
50+
$this->scopeType = 'default';
51+
$this->scopeCode = null;
52+
53+
$this->model = new EngineResolver(
54+
$this->scopeConfig,
55+
$this->path,
56+
$this->scopeType,
57+
$this->scopeCode
58+
);
59+
}
60+
61+
/**
62+
* Test getCurrentSearchEngine
63+
*/
64+
public function testGetCurrentSearchEngine()
65+
{
66+
$engine = 'mysql';
67+
68+
$this->scopeConfig->expects($this->any())
69+
->method('getValue')
70+
->willReturn($engine);
71+
72+
$this->assertEquals($engine, $this->model->getCurrentSearchEngine());
73+
}
74+
}

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

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
</argument>
3232
</arguments>
3333
</type>
34+
<type name="Magento\Search\Model\EngineResolver">
35+
<arguments>
36+
<argument name="path" xsi:type="string">catalog/search/engine</argument>
37+
<argument name="scopeType" xsi:type="string">default</argument>
38+
</arguments>
39+
</type>
3440
<preference for="Magento\Search\Model\AutocompleteInterface" type="Magento\Search\Model\Autocomplete" />
3541
<preference for="Magento\Search\Model\Autocomplete\ItemInterface" type="Magento\Search\Model\Autocomplete\Item" />
3642
<preference for="Magento\Framework\Search\SearchEngineInterface" type="Magento\Search\Model\SearchEngine"/>

app/code/Magento/Ui/view/base/web/js/form/components/tab_group.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,29 @@ define([
5757
* @param {Object} elem
5858
*/
5959
validate: function (elem) {
60-
var source = this.source,
61-
result = elem.delegate('validate'),
62-
invalid = false;
60+
var result = elem.delegate('validate'),
61+
invalid;
6362

64-
_.some(result, function (item) {
65-
return !item.valid && (invalid = item.target);
63+
invalid = _.find(result, function (item) {
64+
return !item.valid;
6665
});
6766

68-
if (invalid && !source.get('params.invalid')) {
69-
source.set('params.invalid', true);
70-
67+
if (invalid) {
7168
elem.activate();
72-
invalid.focused(true);
69+
invalid.target.focused(true);
7370
}
71+
72+
return invalid;
7473
},
7574

7675
/**
7776
* Sets 'allValid' property of instance to true, then calls 'validate' method
7877
* of instance for each element.
7978
*/
8079
onValidate: function () {
81-
var elems;
82-
83-
elems = this.elems.sortBy(function (elem) {
80+
this.elems.sortBy(function (elem) {
8481
return !elem.active();
85-
});
86-
87-
elems.forEach(this.validate, this);
82+
}).some(this.validate, this);
8883
}
8984
});
9085
});

0 commit comments

Comments
 (0)