9 use \Magento\Framework\Data\Form\AbstractForm;
40 $this->factoryElementMock =
41 $this->createPartialMock(\
Magento\Framework\Data\
Form\Element\Factory::class, [
'create']);
42 $this->factoryCollectionMock =
43 $this->createPartialMock(\
Magento\Framework\Data\
Form\Element\CollectionFactory::class, [
'create']);
44 $this->allElementsMock =
45 $this->createMock(\
Magento\Framework\Data\
Form\Element\Collection::class);
47 $this->createMock(\
Magento\Framework\Data\
Form\Element\AbstractElement::class);
49 $this->abstractForm =
new AbstractForm($this->factoryElementMock, $this->factoryCollectionMock, []);
54 $this->factoryCollectionMock
55 ->expects($this->once())
57 ->will($this->returnValue($this->allElementsMock));
58 $this->elementMock->expects($this->once())->method(
'setForm');
59 $this->allElementsMock->expects($this->once())->method(
'add')->with($this->elementMock,
false);
60 $this->abstractForm->addElement($this->elementMock,
false);
65 $config = [
'name' =>
'store_type',
'no_span' =>
true,
'value' =>
'value'];
66 $this->factoryElementMock
67 ->expects($this->once())
69 ->with(
'hidden', [
'data' =>
$config])
70 ->will($this->returnValue($this->elementMock));
71 $this->elementMock->expects($this->once())->method(
'setId')->with(
'store_type');
72 $this->factoryCollectionMock
73 ->expects($this->once())
75 ->will($this->returnValue($this->allElementsMock));
76 $this->allElementsMock->expects($this->once())->method(
'add')->with($this->elementMock,
false);
77 $this->assertEquals($this->elementMock, $this->abstractForm->addField(
'store_type',
'hidden',
$config));
78 $this->abstractForm->removeField(
'hidden');
83 $config = [
'name' =>
'store_type',
'no_span' =>
true,
'value' =>
'value'];
84 $this->factoryElementMock
85 ->expects($this->once())
87 ->with(
'fieldset', [
'data' =>
$config])
88 ->will($this->returnValue($this->elementMock));
89 $this->elementMock->expects($this->once())->method(
'setId')->with(
'hidden');
90 $this->elementMock->expects($this->once())->method(
'setAdvanced')->with(
false);
91 $this->elementMock->expects($this->once())->method(
'setForm');
92 $this->factoryCollectionMock
93 ->expects($this->once())
95 ->will($this->returnValue($this->allElementsMock));
96 $this->allElementsMock->expects($this->once())->method(
'add')->with($this->elementMock,
false);
97 $this->abstractForm->addFieldset(
'hidden',
$config);
102 $config = [
'name' =>
'store_type',
'no_span' =>
true,
'value' =>
'value'];
103 $this->factoryElementMock
104 ->expects($this->once())
106 ->with(
'column', [
'data' =>
$config])
107 ->will($this->returnValue($this->elementMock));
108 $this->elementMock->expects($this->once())->method(
'setId')->with(
'hidden');
109 $this->elementMock->expects($this->exactly(2))->method(
'setForm')->will($this->returnSelf());
110 $this->factoryCollectionMock
111 ->expects($this->once())
113 ->will($this->returnValue($this->allElementsMock));
114 $this->allElementsMock->expects($this->once())->method(
'add')->with($this->elementMock,
false);
115 $this->abstractForm->addColumn(
'hidden',
$config);
122 $this->abstractForm->addCustomAttribute(
'attribute_key1',
'attribute_value1')
126 $this->assertNotEquals(
128 $this->abstractForm->addCustomAttribute(
'attribute_key2',
'attribute_value2')
146 $this->abstractForm->setData($key,
$value);
150 $this->abstractForm->addCustomAttribute($key,
$value);
153 $this->assertEquals(
$result, $this->abstractForm->serialize($keys));
168 [[
'key1'], [], [],
''],
169 [[
'key1'], [
'key1' =>
'value'], [],
'key1="value"'],
170 [[
'key1',
'key2'], [
'key1' =>
'value'], [],
'key1="value"'],
171 [[
'key1',
'key2'], [
'key1' =>
'value',
'key3' =>
'value3'], [],
'key1="value"'],
172 [[
'key1',
'key2'], [
'key1' =>
'value',
'key3' =>
'value3'], [
'custom1' =>
''],
'key1="value"'],
183 'custom1' =>
'custom_value1',
185 'key1="value" custom1="custom_value1"' 197 'custom1' =>
'custom_value1',
203 'key1="value" custom1="custom_value1"'