-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-37363: [GITHUB] dist front: search is broken #1268
- Loading branch information
Maksym Aposov
committed
May 13, 2015
1 parent
b4eb24a
commit 3a9946a
Showing
10 changed files
with
172 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/code/Magento/Eav/Block/Adminhtml/Attribute/PropertyLocker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Eav\Block\Adminhtml\Attribute; | ||
|
||
use Magento\Framework\Registry; | ||
use Magento\Eav\Model\Entity\Attribute\Config; | ||
|
||
/** | ||
* Disable form fields | ||
* | ||
* @author Magento Core Team <core@magentocommerce.com> | ||
*/ | ||
class PropertyLocker | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
private $attributeConfig; | ||
|
||
/** | ||
* @var Registry | ||
*/ | ||
protected $registry; | ||
|
||
/** | ||
* @param Registry $registry | ||
* @param Config $attributeConfig | ||
*/ | ||
public function __construct( | ||
Registry $registry, | ||
Config $attributeConfig | ||
) { | ||
$this->registry = $registry; | ||
$this->attributeConfig = $attributeConfig; | ||
} | ||
|
||
/** | ||
* @param \Magento\Framework\Data\Form $form | ||
* @return void | ||
*/ | ||
public function lock(\Magento\Framework\Data\Form $form) | ||
{ | ||
/** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attributeObject */ | ||
$attributeObject = $this->registry->registry('entity_attribute'); | ||
if ($attributeObject->getId()) { | ||
foreach ($this->attributeConfig->getLockedFields($attributeObject) as $field) { | ||
if ($element = $form->getElement($field)) { | ||
$element->setDisabled(1); | ||
$element->setReadonly(1); | ||
} | ||
} | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Eav\Test\Unit\Block\Adminhtml\Attribute; | ||
|
||
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker; | ||
|
||
class PropertyLockerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var PropertyLocker */ | ||
protected $object; | ||
|
||
/** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $attributeMock; | ||
|
||
/** @var \Magento\Framework\Data\Form|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $formMock; | ||
|
||
/** @var \Magento\Eav\Model\Entity\Attribute\Config|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $attributeConfigMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->attributeMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\AbstractAttribute') | ||
->setMethods(['getId']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$registryMock = $this->getMockBuilder('\Magento\Framework\Registry') | ||
->setMethods(['registry']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$registryMock->expects($this->atLeastOnce())->method('registry')->willReturn($this->attributeMock); | ||
|
||
$this->attributeConfigMock = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Config') | ||
->setMethods(['getLockedFields']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->formMock = $this->getMockBuilder('Magento\Framework\Data\Form') | ||
->setMethods(['getElement']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->object = new PropertyLocker($registryMock, $this->attributeConfigMock); | ||
} | ||
|
||
/** | ||
* @covers \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker::lock | ||
*/ | ||
public function testLock() | ||
{ | ||
$lockedFields = [ | ||
'is_searchable' => 'is_searchable', | ||
'is_filterable' => 'is_filterable' | ||
]; | ||
$this->attributeMock->expects($this->once())->method('getId')->willReturn(1); | ||
$this->attributeConfigMock->expects($this->once())->method('getLockedFields')->willReturn($lockedFields); | ||
|
||
$elementMock = $this->getMockBuilder('\Magento\Framework\Data\Form\Element\AbstractElement') | ||
->setMethods(['setDisabled', 'setReadonly']) | ||
->disableOriginalConstructor() | ||
->getMockForAbstractClass(); | ||
$elementMock->expects($this->exactly(2))->method('setDisabled'); | ||
$elementMock->expects($this->exactly(2))->method('setReadonly'); | ||
$this->formMock->expects($this->exactly(2))->method('getElement')->willReturn($elementMock); | ||
$this->object->lock($this->formMock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters