5
5
*/
6
6
namespace Magento \Catalog \Test \Unit \Block \Adminhtml \Product \Attribute \Edit \Tab ;
7
7
8
+ use Magento \Eav \Block \Adminhtml \Attribute \PropertyLocker ;
9
+
8
10
class AdvancedTest extends \PHPUnit_Framework_TestCase
9
11
{
10
12
/**
@@ -41,38 +43,46 @@ class AdvancedTest extends \PHPUnit_Framework_TestCase
41
43
* @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
42
44
*/
43
45
protected $ filesystem ;
46
+
47
+ /**
48
+ * @var PropertyLocker|\PHPUnit_Framework_MockObject_MockObject
49
+ */
50
+ private $ propertyLocker ;
44
51
45
52
protected function setUp ()
46
53
{
47
54
$ 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 );
54
62
55
63
$ 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 ,
57
65
[
58
66
'registry ' => $ this ->registry ,
59
67
'formFactory ' => $ this ->formFactory ,
60
68
'localeDate ' => $ this ->localeDate ,
61
69
'yesNo ' => $ this ->yesNo ,
62
70
'eavData ' => $ this ->eavData ,
63
- 'filesystem ' => $ this ->filesystem
71
+ 'filesystem ' => $ this ->filesystem ,
72
+ 'propertyLocker ' => $ this ->propertyLocker
64
73
]
65
74
);
75
+ $ objectManager ->setBackwardCompatibleProperty ($ this ->block , 'propertyLocker ' , $ this ->propertyLocker );
66
76
}
67
77
68
78
public function testToHtml ()
69
79
{
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 );
76
86
77
87
$ this ->registry ->expects ($ this ->any ())->method ('registry ' )->with ('entity_attribute ' )
78
88
->willReturn ($ attributeModel );
@@ -93,6 +103,7 @@ public function testToHtml()
93
103
$ this ->yesNo ->expects ($ this ->any ())->method ('toOptionArray ' )->willReturn (['yes ' , 'no ' ]);
94
104
$ this ->filesystem ->expects ($ this ->any ())->method ('getDirectoryRead ' )->willReturn ($ directoryReadInterface );
95
105
$ directoryReadInterface ->expects ($ this ->any ())->method ('getRelativePath ' )->willReturn ('relative_path ' );
106
+ $ this ->propertyLocker ->expects ($ this ->once ())->method ('lock ' )->with ($ form );
96
107
97
108
$ this ->block ->setData (['action ' => 'save ' ]);
98
109
$ this ->block ->toHtml ();
0 commit comments