Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BundleWeightTest.php
Go to the documentation of this file.
1 <?php
7 
11 
13 {
17  protected function createModel()
18  {
19  return $this->objectManager->getObject(
20  BundleWeight::class,
21  ['arrayManager' => $this->arrayManagerMock]
22  );
23  }
24 
28  public function testModifyMeta()
29  {
30  $weightTypePath = 'bundle-items/children/' . BundleWeight::CODE_WEIGHT_TYPE;
31  $weightTypeConfigPath = $weightTypePath . BundleWeight::META_CONFIG_PATH;
32  $weightPath = 'product-details/children/' . ProductAttributeInterface::CODE_WEIGHT;
33  $weightConfigPath = $weightPath . BundleWeight::META_CONFIG_PATH;
34  $hasWeightPath = 'product-details/children/' . ProductAttributeInterface::CODE_HAS_WEIGHT;
35  $hasWeightConfigPath = $hasWeightPath . BundleWeight::META_CONFIG_PATH;
36  $sourceMeta = [
37  'product-details' => [
38  'children' => [
41  ]
42  ],
43  'bundle-items' => [
44  'children' => [
46  ]
47  ]
48  ];
49  $weightTypeParams = [
50  'valueMap' => [
51  'false' => '1',
52  'true' => '0'
53  ],
54  'validation' => [
55  'required-entry' => false
56  ]
57  ];
58  $weightParams = [
59  'imports' => [
60  'disabled' => 'ns = ${ $.ns }, index = ' . BundleWeight::CODE_WEIGHT_TYPE . ':checked',
61  ]
62  ];
63  $hasWeightParams = [
64  'disabled' => true,
65  'visible' => false
66  ];
67  $weightTypeMeta = [
68  'product-details' => [
69  'children' => [
72  ]
73  ],
74  'bundle-items' => [
75  'children' => [
76  BundleWeight::CODE_WEIGHT_TYPE => $weightTypeParams
77  ]
78  ]
79  ];
80  $hasWeightMeta = [
81  'product-details' => [
82  'children' => [
85  ]
86  ],
87  'bundle-items' => [
88  'children' => [
89  BundleWeight::CODE_WEIGHT_TYPE => $weightTypeParams
90  ]
91  ]
92  ];
93  $weightMeta = [
94  'product-details' => [
95  'children' => [
98  ]
99  ],
100  'bundle-items' => [
101  'children' => [
102  BundleWeight::CODE_WEIGHT_TYPE => $weightTypeParams
103  ]
104  ]
105  ];
106 
107  $this->arrayManagerMock->expects(static::any())
108  ->method('findPath')
109  ->willReturnMap(
110  [
111  [
113  $sourceMeta,
114  null,
115  'children',
117  $weightTypePath
118  ],
119  [
121  $weightTypeMeta,
122  null,
123  'children',
125  $hasWeightPath
126  ],
127  [
129  $hasWeightMeta,
130  null,
131  'children',
133  $weightPath
134  ]
135  ]
136  );
137  $this->arrayManagerMock->expects($this->exactly(3))
138  ->method('merge')
139  ->willReturnMap(
140  [
141  [
142  $weightTypeConfigPath,
143  $sourceMeta,
144  $weightTypeParams,
146  $weightTypeMeta
147  ],
148  [
149  $hasWeightConfigPath,
150  $weightTypeMeta,
151  $hasWeightParams,
153  $hasWeightMeta
154  ],
155  [
156  $weightConfigPath,
157  $hasWeightMeta,
158  $weightParams,
160  $weightMeta
161  ]
162  ]
163  );
164 
165  $this->assertSame($weightMeta, $this->getModel()->modifyMeta($sourceMeta));
166  }
167 
168  public function testModifyData()
169  {
170  $expectedData = [];
171  $this->assertEquals($expectedData, $this->getModel()->modifyData($expectedData));
172  }
173 }
return false
Definition: gallery.phtml:36