Skip to content

Commit 1f0b2ed

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-63657' into 2.0.15-develop-pr14
2 parents 1ad6a5a + 4e67226 commit 1f0b2ed

File tree

3 files changed

+51
-14
lines changed

3 files changed

+51
-14
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Backend\Block\Widget\Form\Generic;
1717
use Magento\Config\Model\Config\Source\Yesno;
1818
use Magento\Eav\Helper\Data;
19+
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
20+
use Magento\Framework\App\ObjectManager;
1921

2022
class Advanced extends Generic
2123
{
@@ -36,6 +38,13 @@ class Advanced extends Generic
3638
*/
3739
protected $disableScopeChangeList;
3840

41+
/**
42+
* Disable form fields.
43+
*
44+
* @var \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker PropertyLocker
45+
*/
46+
private $propertyLocker;
47+
3948
/**
4049
* @param \Magento\Backend\Block\Template\Context $context
4150
* @param \Magento\Framework\Registry $registry
@@ -241,6 +250,8 @@ protected function _prepareForm()
241250
$form->getElement('is_global')->setDisabled(1);
242251
}
243252
$this->setForm($form);
253+
$this->getPropertyLocker()->lock($form);
254+
244255
return $this;
245256
}
246257

@@ -264,4 +275,18 @@ private function getAttributeObject()
264275
{
265276
return $this->_coreRegistry->registry('entity_attribute');
266277
}
278+
279+
/**
280+
* Get property locker.
281+
*
282+
* @return PropertyLocker
283+
*/
284+
private function getPropertyLocker()
285+
{
286+
if (null === $this->propertyLocker) {
287+
$this->propertyLocker = ObjectManager::getInstance()->get(PropertyLocker::class);
288+
}
289+
290+
return $this->propertyLocker;
291+
}
267292
}

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Edit\Tab;
77

8+
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
9+
810
class AdvancedTest extends \PHPUnit_Framework_TestCase
911
{
1012
/**
@@ -41,38 +43,46 @@ class AdvancedTest extends \PHPUnit_Framework_TestCase
4143
* @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
4244
*/
4345
protected $filesystem;
46+
47+
/**
48+
* @var PropertyLocker|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
private $propertyLocker;
4451

4552
protected function setUp()
4653
{
4754
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
48-
$this->registry = $this->getMock('\Magento\Framework\Registry');
49-
$this->formFactory = $this->getMock('Magento\Framework\Data\FormFactory', [], [], '', false);
50-
$this->yesNo = $this->getMock('Magento\Config\Model\Config\Source\Yesno');
51-
$this->localeDate = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface');
52-
$this->eavData = $this->getMock('Magento\Eav\Helper\Data', [], [], '', false);
53-
$this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
55+
$this->registry = $this->getMock(\Magento\Framework\Registry::class);
56+
$this->formFactory = $this->getMock(\Magento\Framework\Data\FormFactory::class, [], [], '', false);
57+
$this->yesNo = $this->getMock(\Magento\Config\Model\Config\Source\Yesno::class);
58+
$this->localeDate = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
59+
$this->eavData = $this->getMock(\Magento\Eav\Helper\Data::class, [], [], '', false);
60+
$this->filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false);
61+
$this->propertyLocker = $this->getMock(PropertyLocker::class, [], [], '', false);
5462

5563
$this->block = $objectManager->getObject(
56-
'Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced',
64+
\Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced::class,
5765
[
5866
'registry' => $this->registry,
5967
'formFactory' => $this->formFactory,
6068
'localeDate' => $this->localeDate,
6169
'yesNo' => $this->yesNo,
6270
'eavData' => $this->eavData,
63-
'filesystem' => $this->filesystem
71+
'filesystem' => $this->filesystem,
72+
'propertyLocker' => $this->propertyLocker
6473
]
6574
);
75+
$objectManager->setBackwardCompatibleProperty($this->block, 'propertyLocker', $this->propertyLocker);
6676
}
6777

6878
public function testToHtml()
6979
{
70-
$fieldSet = $this->getMock('Magento\Framework\Data\Form\Element\Fieldset', [], [], '', false);
71-
$form = $this->getMock('Magento\Framework\Data\Form', [], [], '', false);
72-
$attributeModel = $this->getMock('\Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false);
73-
$entityType = $this->getMock('Magento\Eav\Model\Entity\Type', [], [], '', false);
74-
$formElement = $this->getMock('Magento\Framework\Data\Form\Element\Text', ['setDisabled'], [], '', false);
75-
$directoryReadInterface = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface');
80+
$fieldSet = $this->getMock(\Magento\Framework\Data\Form\Element\Fieldset::class, [], [], '', false);
81+
$form = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false);
82+
$attributeModel = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false);
83+
$entityType = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false);
84+
$formElement = $this->getMock(\Magento\Framework\Data\Form\Element\Text::class, ['setDisabled'], [], '', false);
85+
$directoryReadInterface = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class);
7686

7787
$this->registry->expects($this->any())->method('registry')->with('entity_attribute')
7888
->willReturn($attributeModel);
@@ -93,6 +103,7 @@ public function testToHtml()
93103
$this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
94104
$this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
95105
$directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
106+
$this->propertyLocker->expects($this->once())->method('lock')->with($form);
96107

97108
$this->block->setData(['action' => 'save']);
98109
$this->block->toHtml();

app/code/Magento/Catalog/etc/eav_attributes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<field code="is_searchable" locked="true" />
3131
</attribute>
3232
<attribute code="category_ids">
33+
<field code="is_global" locked="true" />
3334
<field code="is_searchable" locked="true" />
3435
</attribute>
3536
<attribute code="media_gallery">

0 commit comments

Comments
 (0)